-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path17_classes.py
More file actions
55 lines (40 loc) · 1.07 KB
/
Copy path17_classes.py
File metadata and controls
55 lines (40 loc) · 1.07 KB
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
class Vehicule:
def __init__(self, make, model):
self.make = make
self.model = model
def moves(self):
print("Moves along ..")
def get_make_model(self):
print(f"I'am {self.make} {self.model}")
mycar = Vehicule("Tesla", "Model 3")
# print(mycar.make)
# print(mycar.model)
mycar.get_make_model()
mycar.moves()
yourcar = Vehicule("Toyota", "Hilux")
yourcar.get_make_model()
yourcar.moves()
class Airplane(Vehicule):
def __init__(self, make, model, faa_id):
super().__init__(make, model)
self.faa_id = faa_id
def moves(self):
print("Flies along ..")
class Truck(Vehicule):
def moves(self):
print("Rumbles along ..")
class Golfcart(Vehicule):
pass
cessna = Airplane('Cessna', 'Skyhawk', 'N-12345')
mack = Truck('Mack', 'pinnacle')
golfwagon = Golfcart('Yamaha', 'GC100')
cessna.get_make_model()
cessna.moves()
mack.get_make_model()
mack.moves()
golfwagon.get_make_model()
golfwagon.moves()
print('\n\n')
for v in (mycar, yourcar, cessna, mack, golfwagon):
v.get_make_model()
v.moves()