Repository navigation
Expand file tree
/
Copy pathoop1.py
More file actions
64 lines (55 loc) · 1.36 KB
/
Copy pathoop1.py
File metadata and controls
64 lines (55 loc) · 1.36 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
59
60
61
62
63
64
# Write classes for the following class hierarchy:
#
# [Vehicle]->[FlightVehicle]->[Starship]
# | |
# v v
# [GroundVehicle] [Airplane]
# | |
# v v
# [Car] [Motorcycle]
#
# Each class can simply "pass" for its body. The exercise is about setting up
# the hierarchy.
#
# e.g.
#
# class Whatever:
# pass
#
# Put a comment noting which class is the base class
#Base class
class Vehicle():
def __init__(self):
pass
class FlightVehicle(Vehicle):
def __init__(self):
super().__init__()
pass
class Starship(FlightVehicle):
def __init__(self):
super().__init__()
pass
class Airplane(FlightVehicle):
def __init__(self):
super().__init__()
pass
class GroundVehicle(Vehicle):
def __init__(self):
super().__init__()
pass
class Car(GroundVehicle):
def __init__(self):
super().__init__()
pass
class Motorcycle(GroundVehicle):
def __init__(self):
super().__init__()
pass
#Check to see if hierarchies are set up correctly:
print(issubclass(FlightVehicle, Vehicle))
print(issubclass(Starship, FlightVehicle))
print(issubclass(Starship, Vehicle))
print(issubclass(Airplane, FlightVehicle))
print(issubclass(Airplane, Vehicle))
print(issubclass(GroundVehicle, Vehicle))
print(issubclass(Car, Vehicle))