-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule6_3.py
More file actions
40 lines (30 loc) · 746 Bytes
/
Copy pathmodule6_3.py
File metadata and controls
40 lines (30 loc) · 746 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
class Horse:
def __init__(self):
self.x_distance = 0
self.sound = 'Frrr'
def run(self, dx):
self.x_distance += dx
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
class Pegasus(Horse, Eagle):
def __init__(self):
Horse.__init__(self)
Eagle.__init__(self)
def move(self, dx, dy):
self.run(dx)
self.fly(dy)
def get_pos(self):
return self.x_distance, self.y_distance
def voice(self):
print(self.sound)
p1 = Pegasus()
print(p1.get_pos())
p1.move(10, 15)
print(p1.get_pos())
p1.move(-5, 20)
print(p1.get_pos())
p1.voice()