-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_6_3.py
More file actions
50 lines (33 loc) · 931 Bytes
/
module_6_3.py
File metadata and controls
50 lines (33 loc) · 931 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
45
46
47
48
49
50
class Horse:
def __init__(self):
self.x_distance = 0
self.__sound = 'Frrr'
def run(self, dx):
self.x_distance += dx
return self.x_distance
class Eagle:
def __init__(self):
self.y_distance = 0
self.sound = 'I train, eat, sleep, and repeat'
def fly(self, dy):
self.y_distance += dy
return self.y_distance
def voice(self):
return self.sound
class Pegasus(Horse, Eagle):
def __init__(self):
super().__init__()
Eagle.__init__(self)
def move(self, dx, dy):
return super().run(dx), Eagle.fly(self, dy)
def get_pos(self):
return (self.x_distance, self.y_distance)
def voice(self):
print(Eagle.voice(self))
p1 = Pegasus()
print(p1.get_pos())
p1.move(10, 15)
print(p1.get_pos())
p1.move(-5, 20)
print(p1.get_pos())
p1.voice()