-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.py
More file actions
44 lines (29 loc) · 975 Bytes
/
5.py
File metadata and controls
44 lines (29 loc) · 975 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
43
44
class Stationery():
count_stationery = 0
def __init__(self, title):
Stationery.count_stationery += 1
self.title = title
def draw(self):
print('start draw')
class Mod_Stationery(Stationery): # чтобы не перегружать методы в каждом классе добавил мод
def __init__(self, title):
super().__init__(title)
def draw(self):
print(f'start draw by {self.title}')
class Pen(Mod_Stationery):
def __init__(self):
super().__init__('pen')
def draw(self):
print(f'PEN start draw by {self.title}') # но можно и перегрузить в каждом классе как по заданию
class Pencil(Mod_Stationery):
def __init__(self):
super().__init__('pencil')
class Handle(Mod_Stationery):
def __init__(self):
super().__init__('handle')
pn = Pen()
pl = Pencil()
hl = Handle()
pn.draw()
pl.draw()
hl.draw()