-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathadapter_better.py
46 lines (30 loc) · 865 Bytes
/
adapter_better.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
class Elf:
def nall_nin(self):
print('Elf says: Calling the Overlord ...')
class Dwarf:
def estver_narho(self):
print('Dwarf says: Calling the Overlord ...')
class Human:
def ring_mig(self):
print('Human says: Calling the Overlord ...')
class ElfAdapter:
def __init__(self, elf):
self.elf = elf
def call_me(self):
self.elf.nall_nin()
class DwarfAdapter:
def __init__(self, dwarf):
self.dwarf = dwarf
def call_me(self):
self.dwarf.estver_narho()
class HumanAdapter:
def __init__(self, human):
self.human = human
def call_me(self):
self.human.ring_mig()
if __name__ == '__main__':
minions = [ElfAdapter(Elf()),
DwarfAdapter(Dwarf()),
HumanAdapter(Human())]
for minion in minions:
minion.call_me()