-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOP_3.py
More file actions
50 lines (39 loc) · 1.04 KB
/
OOP_3.py
File metadata and controls
50 lines (39 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
37
38
39
40
41
42
43
44
45
46
47
48
49
class Krug:
def __init__(self, radius, color):
self.radius = radius
self.color = color
class Kvadrat:
def __init__(self, height, color):
self.height = height
self.color = color
class Treugolnik:
def __init__(self, height, color):
self.height = height
self.color = color
class Box:
def __init__(self):
self.figures = []
def add(self, something):
self.figures.append(something)
def check(self):
inthebox = []
for el in self.figures:
if isinstance(el, Krug):
inthebox.append('krug')
elif isinstance(el, Kvadrat):
inthebox.append('kvadrat')
elif isinstance(el, Treugolnik):
inthebox.append('treugolnik')
print(inthebox)
return(inthebox)
figura = Krug(10, 'red')
eshe_firura = Kvadrat(15, 'blue')
poslednyaya_fiura = Treugolnik(5, 'yellow')
box = Box()
box.add(figura)
box.check()
print()
box.add(eshe_firura)
box.add(figura)
box.add(figura)
box.check()