Programming Logic and Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
Admin
Admin
Admin
Posts : 7
Join date : 2018-08-07
https://jenreyes.forumotion.com

Composition Empty Composition

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 .

Composition 1111110


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

Composition Empty Re: Composition

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

Composition Empty Re: Composition

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

Composition Empty Re: Composition

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

Composition Empty Re: Composition

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.
Jenny2426
Jenny2426
Guru
Guru
Posts : 10
Join date : 2018-08-16

Composition Empty Re: Composition

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

Composition Empty Re: Composition

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

Composition Empty Re: Composition

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