-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11-square.py
More file actions
executable file
·36 lines (31 loc) · 1.04 KB
/
Copy path11-square.py
File metadata and controls
executable file
·36 lines (31 loc) · 1.04 KB
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
30
31
32
33
34
35
36
#!/usr/bin/python3
"""
Module 10-square
Contains parent class BaseGeometry
with public instance method area and integer_validation
Contains subclass Rectangle
with instantiation of private attributes width and height, validated by parent,
extends parent's area method and prints with __str__
Contains subclass Square
with instantiation of private attribute size, validated by superclass,
and prints with __str__
"""
Rectangle = __import__('9-rectangle').Rectangle
class Square(Rectangle):
"""inherits from Rectangle, who inherits from BaseGeometry
methods:
__init__(self, size)
__str__(self)
"""
def __init__(self, size):
"""initializes size
Args:
size (int): private
"""
self.integer_validator("size", size)
super().__init__(size, size)
self.__size = size
def __str__(self):
"""prints [Rectangle] <width>/<height>"""
return "[{:s}] {:d}/{:d}".format(self.__class__.__name__,
self.__size, self.__size)