Skip to content

Commit b09092a

Browse files
committed
Update #1
1 parent 11ff2da commit b09092a

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

0x0C-python-almost_a_circle/models/rectangle.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,43 @@ def display(self):
105105
console with #
106106
'''
107107
for col in range(self.x):
108-
print()
108+
print()
109109
for y_axis in range(self.height):
110110
for x_axis in range(self.y):
111-
print(' ' , end='')
111+
print(' ', end='')
112112
for row in range(self.width):
113113
print('#', end='')
114114
print()
115-
116115

117116
def __str__(self):
118117
'''
119118
String representation
120119
'''
121-
return '[Rectangle] ({}) {}/{} - {}/{} '.format(self.id, self.x, self.y, self.width, self.height)
122-
120+
return '[Rectangle] ({}) {}/{} - {}/{} '.format(self.id,
121+
self.x, self.y, self.width, self.height)
122+
123123
def update(self, *args, **kwargs):
124124
'''
125125
Allows for variadic args
126126
'''
127127
argc = len(args)
128-
try:
129-
self.id = args[0]
130-
self.width = args[1]
131-
self.height = args[2]
132-
self.x = args[3]
133-
self.y = args[4]
134-
except IndexError:
135-
pass
136-
137-
128+
if argc > 0:
129+
try:
130+
self.id = args[0]
131+
self.width = args[1]
132+
self.height = args[2]
133+
self.x = args[3]
134+
self.y = args[4]
135+
except IndexError:
136+
pass
137+
else:
138+
if 'id' in kwargs:
139+
self.id = kwargs['id']
140+
if 'width' in kwargs:
141+
self.width = kwargs['width']
142+
if 'height' in kwargs:
143+
self.height = kwargs['height']
144+
if 'x' in kwargs:
145+
self.x = kwargs['x']
146+
if 'y' in kwargs:
147+
self.y = kwargs['y']

0 commit comments

Comments
 (0)