-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy path9-rectangle.py
More file actions
executable file
·29 lines (23 loc) · 965 Bytes
/
9-rectangle.py
File metadata and controls
executable file
·29 lines (23 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python3
"""Defines a class Rectangle that inherits from BaseGeometry."""
BaseGeometry = __import__('7-base_geometry').BaseGeometry
class Rectangle(BaseGeometry):
"""Represent a rectangle using BaseGeometry."""
def __init__(self, width, height):
"""Intialize a new Rectangle.
Args:
width (int): The width of the new Rectangle.
height (int): The height of the new Rectangle.
"""
super().integer_validator("width", width)
self.__width = width
super().integer_validator("height", height)
self.__height = height
def area(self):
"""Return the area of the rectangle."""
return self.__width * self.__height
def __str__(self):
"""Return the print() and str() representation of a Rectangle."""
string = "[" + str(self.__class__.__name__) + "] "
string += str(self.__width) + "/" + str(self.__height)
return string