0% found this document useful (0 votes)
4 views1 page

Oops 2 08

The document describes a Python code snippet demonstrating an Employee class that utilizes a Car class, showcasing methods for displaying employee information and actions. It also explains the concept of composition in object-oriented programming, highlighting the strong association between container and contained objects, with the example of a University containing Departments. The document concludes with contact information for Durgasoft.

Uploaded by

vishnu050621
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Oops 2 08

The document describes a Python code snippet demonstrating an Employee class that utilizes a Car class, showcasing methods for displaying employee information and actions. It also explains the concept of composition in object-oriented programming, highlighting the strong association between container and contained objects, with the example of a University containing Departments. The document concludes with contact information for Durgasoft.

Uploaded by

vishnu050621
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

25) print("Employee Name:",self.

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

You might also like