-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path185 Ducks.py
70 lines (46 loc) · 1.24 KB
/
185 Ducks.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
68
69
70
class Wing(object):
def __init__(self, ratio):
self.ratio = ratio
def fly(self):
if self.ratio > 1:
print("Ale zabawa!")
elif self.ratio == 1:
print("Ciężko ale latam")
else:
print("Chyba sobie pochodzę")
class Duck(object):
def __init__(self):
self._wing = Wing(1.8 )
def walk(self):
print("Klap, klap, klap")
def swim(self):
print("Chodź popływać")
def quack(self):
print("Kwa, kwa, kwa")
def fly(self):
self._wing.fly()
class Penguin(object):
def walk(self):
print("Klap, klap, klap, też człapię")
def swim(self):
print("Chodź, ale uważaj, woda tu jest dużo chłodniejsza")
def quack(self):
print("Jestem pingwin i nie kwaczę")
# def test_duck(duck):
# duck.walk()
# duck.swim()
# duck.quack()
class Flock(object):
def __init__(self):
self.flock = []
def add_duck(self, duck):
self.flock.append(duck)
def migrate(self):
for duck in self.flock:
duck.fly()
if __name__ == "__main__":
donald = Duck()
donald.fly()
# test_duck(donald)
# szeregowy = Penguin()
# test_duck(szeregowy)