-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDALIGDIG_final_exam_problem_3.py
50 lines (38 loc) · 1.18 KB
/
DALIGDIG_final_exam_problem_3.py
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
# Parent1 Class
class Vehicle():
wheels = None
def __init__(self, wheels):
self.wheels = wheels
def display(self):
print("The vehicle has {} wheels.".format(self.wheels))
# Parent2 Class
class Asset(Vehicle):
price = None
def __init__(self, price, wheels):
self.price = price
Vehicle.__init__(self,wheels)
def display(self):
print("The asset is worth {} pesos.".format(self.price))
# Child Class
class Car(Asset):
brand = None
def __init__(self, brand, price, wheels):
self.brand = brand
Asset.__init__(self, price, wheels)
def display(self):
super().display()
print("Brand is {}.".format(self.brand))
# Child of Car Class
class Estate(Car):
model = ''
gears = 0
def __init__(self, model,gears, wheels,brand, price,):
self.model = model
self.gears = gears
Car.__init__(self, brand, price, wheels)
def display(self):
super().display()
print("{} has {} gears.".format(self.model, self.gears))
if __name__ == "__main__":
e = Estate("S",5,4,"Tesla",3000000)
e.display()