-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangle.py
51 lines (42 loc) · 1.21 KB
/
Rectangle.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Python CMD program, object-oriented shape class and subclasses, enter the shape's name, color and other attributes
to construct them and calculate the area and perimeter.
using Python version 3.11.4
@version : 1.0
@license: MIT License
@author : Arman Azarnik
contact me at : [email protected]
"""
from Shape import Shape
from abc import abstractmethod
class Rectangle(Shape):
"""
Rectangle class, subclass of Shape class
"""
count = 0
def __init__(self, color, l = None , w = None):
super().__init__(color)
self.set_lenght(l)
self.set_width(w)
Rectangle.count += 1
def __del__(self):
Rectangle.count -= 1
def get_shape(self):
return "rectangle"
def get_color(self):
return super().get_color()
@abstractmethod
def get_lenght(self):
return self.lenght
@abstractmethod
def get_width(self):
return self.width
def set_lenght(self, l = None):
if l == None or l <= 0:
self.lenght = 1
else:
self.lenght = l
def set_width(self, w = None):
if w == None or w <= 0:
self.width = 1
else:
self.width = w