Oops 2 08
Oops 2 08
name)
26) print("Employee Age:",self.age)
27) print("Employee Number:",self.eno)
28) print("Employee Salary:",self.esal)
29) print("Employee Car Info:")
30) self.car.getinfo()
31)
32) c=Car("Innova","2.5V","Grey")
33) e=Employee('Durga',48,100,10000,c)
34) e.eatndrink()
35) e.work()
36) e.empinfo()
Output:
Eat Biryani and Drink Beer
Coding Python is very easy just like drinking Chilled Beer
Employee Name: Durga
Employee Age: 48
Employee Number: 100
Employee Salary: 10000
Employee Car Info:
Car Name:Innova
Model:2.5V
Color:Grey
In the above example Employee class extends Person class functionality but just uses Car class
functionality.
Composition vs Aggregation:
Composition:
Without existing container object if there is no chance of existing contained object then the
container and contained objects are strongly associated and that strong association is nothing but
Composition.
Eg: University contains several Departments and without existing university object there is no
chance of existing Department object. Hence University and Department objects are strongly
associated and this strong association is nothing but Composition.
nd
DURGASOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
8 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www.durgasoft.com