Showing posts with label Relationships. Show all posts
Showing posts with label Relationships. Show all posts

Thursday, May 10, 2012

Multiplicity

Multiplicity refers to the number of relationships that exists between 2 classes in a composite relationship.

In the diagram below, Player has a 1 to 1 relationship with the Sword class and the Flight class.

Composition: Has-a



"Object composition - Wikipedia, the free encyclopedia" ( http://bit.ly/K0qMRm )

"Has-a - Wikipedia, the free encyclopedia" ( http://bit.ly/JWe9mb )

Composition is a relationship between objects. When one object is composed of others, this is said to be a composite relationship.

In the class diagram below, the Player class has-a relationship with the InventoryItem class. Another was to say this is that the Player class is composed of multiple classes.



Tuesday, March 27, 2012

Inheritence

When once class is derived / extended / inherited from another class, this relationship is said to be 'Inheritance'.

In Java, the extends keyword is used in the class declaration to implement inheritance.



"Inheritance (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)" ( http://bit.ly/OgTDmk )

"Is-a - Wikipedia, the free encyclopedia" ( http://bit.ly/JWeeX1 )

An example class diagram.