-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathassignment_16_12_2021.py
67 lines (44 loc) · 1.12 KB
/
assignment_16_12_2021.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
# create a cash system that has a sender, reciever and a robber.
# create a game using the class polymorphism.
class CashSystem:
def __init__(self, sender, reciever, robber):
self.sender = sender
self.reciever = reciever
self.robber = robber
def send(self):
self.sender.send()
def recieve(self):
self.reciever.recieve()
def rob(self):
self.robber.rob()
class Sender:
def send(self):
print("Sender send money")
class Reciever:
def recieve(self):
print("Reciever recieve money")
class Robber:
def rob(self):
print("Robber steal money")
cash = CashSystem(Sender(), Reciever(), Robber())
cash.send()
cash.recieve()
cash.rob()
class Game:
def __init__(self, player):
self.player = player
def play(self):
self.player.play()
class Player:
def play(self):
print("Player play")
class Player1(Player):
def play(self):
print("Player1 play")
class Player2(Player):
def play(self):
print("Player2 play")
player_1 = Player1()
player_2 = Player2()
player_1.play()
player_2.play()