Share
Go down
avatar
Admin
Posts : 7
Join date : 2018-08-07
View user profilehttp://jenreyes.forumotion.com

Composition

on Wed Aug 08, 2018 2:44 pm
A class can contain simple variables as data fields, and it can contain objects of another class as data fields. For example, you might create a class named Date that contains a month, day, and year, and add two Date fields to an Employee class to hold the Employee ’s birth date and hire date. Then you might create a class named Department that represents every department in a company, and create the Department class to contain a supervisor, who is an Employee .
Figure 11- 11 contains a diagram of these relationships. When a class contains objects of another class, the relationship is called a whole-part relationship or composition . The relationship created is also called a has-a relationship because one class “has an” instance of another—for example, a Department has an Employee and an Employee has a hire Date .




Last edited by Admin on Mon Aug 20, 2018 2:12 pm; edited 1 time in total
Guru
Guru
Posts : 10
Join date : 2018-08-08
View user profile

Re: Composition

on Wed Aug 08, 2018 4:14 pm
does a composition is called an is-a relationship because one class "is an" instance of another?
Guru
Guru
Posts : 10
Join date : 2018-08-08
View user profile

Re: Composition

on Wed Aug 08, 2018 4:18 pm
additional info: A class can contain objects of another class as data fields.
Guru
Guru
Posts : 10
Join date : 2018-08-08
View user profile

Re: Composition

on Wed Aug 08, 2018 4:19 pm
additional info: Composition occurs when you use an object as a field within another class.
Guru
Guru
Posts : 10
Join date : 2018-08-08
View user profile

Re: Composition

on Wed Aug 08, 2018 4:40 pm
Anna06 wrote:does a composition is called an is-a relationship because  one class "is an" instance of another?
Composition is called a has-a relationship because one class "has an" instance of another.
avatar
Guru
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Composition

on Thu Aug 16, 2018 12:34 pm
Anna06 wrote:additional info: A class can contain objects of another class as data fields.
why? Question
Newbie
Newbie
Posts : 4
Join date : 2018-08-18
View user profile

Re: Composition

on Mon Aug 20, 2018 2:27 pm
it is related to database?
Sponsored content

Re: Composition

Back to top
Permissions in this forum:
You cannot reply to topics in this forum