-
Notifications
You must be signed in to change notification settings - Fork 0
/
Composition.py
40 lines (28 loc) · 859 Bytes
/
Composition.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
class Engine:
def __init__(self, capacity=0):
self.capacity = capacity
def printDetails(self):
print("Engine Details: ", self.capacity)
class Tires:
def __init__(self, tires=0):
self.tires = tires
def printDetails(self):
print("Number of Tires: ", self.tires)
class Doors:
def __init__(self, doors=0):
self.doors = doors
def printDetails(self):
print("Number of Doors: ", self.doors)
class Car:
def __init__(self, eng, tr, dr, color):
self.eObj = Engine(eng)
self.tObj = Tires(tr)
self.dObj = Doors(dr)
self.color = color
def printDetails(self):
self.eObj.printDetails()
self.tObj.printDetails()
self.dObj.printDetails()
print("Car Color: ", self.color)
car = Car(1600, 4, 2, "Grey")
car.printDetails()