-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathclasses.py
More file actions
58 lines (40 loc) · 1.08 KB
/
classes.py
File metadata and controls
58 lines (40 loc) · 1.08 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
56
57
58
class Vehicle:
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'm a {self.make} {self.model}.")
my_car = Vehicle('Tesla', 'Model 3')
# print(my_car.make)
# print(my_car.model)
my_car.get_make_model()
my_car.moves()
your_car = Vehicle('Cadillac', 'Escalade')
your_car.get_make_model()
your_car.moves()
class Airplane(Vehicle):
def __init__(self, make, model, faa_id):
super().__init__(make, model)
self.faa_id = faa_id
def moves(self):
print('Flies along..')
class Truck(Vehicle):
def moves(self):
print('Rumbles along..')
class GolfCart(Vehicle):
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 (my_car, your_car, cessna, mack, golfwagon):
v.get_make_model()
v.moves()