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 .
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 .
- Anna06Guru
- Posts : 10
Join date : 2018-08-08
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?
- Anna06Guru
- Posts : 10
Join date : 2018-08-08
Re: Composition
Wed Aug 08, 2018 4:18 pm
additional info: A class can contain objects of another class as data fields.
- Anna06Guru
- Posts : 10
Join date : 2018-08-08
Re: Composition
Wed Aug 08, 2018 4:19 pm
additional info: Composition occurs when you use an object as a field within another class.
- GraceAnnGuru
- Posts : 10
Join date : 2018-08-08
Re: Composition
Wed Aug 08, 2018 4:40 pm
Composition is called a has-a relationship because one class "has an" instance of another.Anna06 wrote:does a composition is called an is-a relationship because one class "is an" instance of another?
- Jenny2426Guru
- Posts : 10
Join date : 2018-08-16
Re: Composition
Thu Aug 16, 2018 12:34 pm
why?Anna06 wrote:additional info: A class can contain objects of another class as data fields.
- NicolaiNewbie
- Posts : 4
Join date : 2018-08-18
Re: Composition
Mon Aug 20, 2018 2:27 pm
it is related to database?
Permissions in this forum:
You cannot reply to topics in this forum
|
|