-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinherit_2.py
More file actions
42 lines (29 loc) · 937 Bytes
/
inherit_2.py
File metadata and controls
42 lines (29 loc) · 937 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
30
31
32
33
34
35
36
37
38
39
40
41
42
class figure:
def __init__(self):
self.color = 'серый'
def change_color(self, new):
self.color = new
print('Поменяли цвет фигуры!')
self.check()
def check(self):
pass
class oval(figure):
def __init__(self, a, b):
super().__init__()
self.x = a
self.y = b
def check(self):
print('Представьте ' + self.color + ' овал с малой полуосью - ' + str(self.x) + ', и большой полуосью - ' + str(self.y))
class square(figure):
def __init__(self, a):
super().__init__()
self.a = a
def check(self):
print('Представьте ' + self.color + ' квадрат со стороной ' + str(self.a))
Oval = oval(1, 2)
Square = square(2)
Oval.check()
Square.check()
print()
Square.change_color('розовый')
Oval.change_color('желтый')