-
Notifications
You must be signed in to change notification settings - Fork 0
/
task10.py
91 lines (59 loc) · 1.93 KB
/
task10.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class Things:
color: str = "white" #error fix
total: int = 0
namething: str = "my name"
def __init__(self, n, t):
self.namething = n
self.total = t
th1 = Things("table", 5)
th2 = Things("computer", 7)
print(th1.namething, th1.total)
print(th2.namething, th2.total)
th1.color = "green"
print(th1.color)
print(th2.color)
class Table:
long: int = 0
width: int = 0
height: int = 0
def __init__(self, l:int, w:int, h:int):
self.long = l
self.width = w
self.height = h
def calc_volume(self):
return self.height*self.width*self.long
def info(self):
print("I am simple table with volume", self.calc_volume())
class BestTable (Table):
name: str = "Graham"
def info(self):
print("I AM BEST TABLE with VOLUME", self.calc_volume(), ' AND I GOT NAME ',self.name)
tables: [Table] = [Table(1,2,3), BestTable(1,2,3)]
for t in tables:
t.info()
class Figure:
color: str = "TITANIUM WHITE"
def change_color(self, new_color: str):
self.color = new_color
def info(self):
print("i am ", self.color," figure")
class Circle(Figure):
radius: int
def __init__(self, r: int):
self.radius = r
def info(self):
print("I am ",self.color, " circle with radius ",self.radius)
class Rectangle(Figure):
length: int
width: int
def __init__(self, l:int, w:int):
self.width = w
self.length = l
def info(self):
print("I am ",self.color, " rectangle with square ", self.length*self.width)
figures: [Figure] = [Figure(), Circle(12), Rectangle(312,2)]
figures[1].change_color("just white")
figures[2].change_color("also black")
for f in figures:
f.info()
# с сотрудниками вообще тоже самое, лень копипасту делать, фантазии у меня мало, хоть я и много чего себе придумываю