-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25_multilevel_inheritance.py
More file actions
59 lines (37 loc) · 1.41 KB
/
Copy path25_multilevel_inheritance.py
File metadata and controls
59 lines (37 loc) · 1.41 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
# vehicle (color, capacity, mode)
# - aeroplane (company, flight_area)
# - cargo aeroplane
# - passenger aeroplane (permittedLuggage)
# - car
# - small car
# - large car
class vehicle:
def __init__(self, color, capacity, mode):
self.color = color
self.capacity = capacity
self.mode = mode
class aeroplane(vehicle):
def __init__(self, color, capacity, company, flight_area):
vehicle.__init__(self, color, capacity, 'air')
self.company = company
self.flight_area = flight_area
class car(vehicle):
def __init__(self, color, capacity, brand, seats):
vehicle.__init__(self, color, capacity, 'road')
self.brand = brand
self.seats = seats
class cargoA(aeroplane):
def __init__(self, company):
aeroplane.__init__(self, "black", 0, company, "domestic")
def info(self):
print(self.company, self.color, self.flight_area, self.capacity, self.mode)
class passA(aeroplane):
def __init__(self, company, capacity, permittedLuggage):
aeroplane.__init__(self, "white", capacity, company, "international")
self.permittedLuggage = permittedLuggage
def info(self):
print(self.company, self.color, self.flight_area, self.capacity, self.mode, self.permittedLuggage)
c = cargoA("Jet Airways")
p = passA("Indigo", "180", "7Kg")
c.info()
p.info()