PPT04_Implementing_Relationships

PPT04_Implementing_Relationships - Implementing...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Implementing Relationships Types of Relationships Association Aggregation Composition Inheritance Implementing Association Create an object reference in one class that references an object of another class. Things to consider What are the reasons for the relationship? Each reason defines one association Why one object needs to know about another object Does each object need to know about the other? Which object is responsible for the relationship? Association Class An association object is one that is created as a result of an association between two other objects. An association object defines the association. RentalCar, Customer, and RentalAgreement. When an association is made between a RentalCar object, and a Customer object, a RentalAgreement object is created. Implementing Aggregation Implemented the same as Association. Additional considerations The aggregate object is responsible for the relationship. Other objects should access component objects through the aggregate object. The aggregate object is responsible for coordination between component objects Implementing Inheritance Generalization/specialization hierarchy General superclass includes attributes and methods that are shared by specialized subclasses Instances of subclass inherit the attributes and methods of the superclass Include additional attributes and methods defined by subclass Keywords: Use extends keyword to implement inheritance public class Pawn extends ChessPiece Use super keyword to invoke superclass constructor super(); To use inheritance: Need to know constructor and method signatures Do not need: Access to source code Knowledge of how class is written Abstract Classes Concrete class Class that can be instantiated Abstract class Class not intended to be instantiated Has at least one abstract method An abstract class must be inherited and the abstract methods must be overriden Page 1 of 4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/15/2010 for the course CSIS 345 taught by Professor Dwightstrong during the Spring '10 term at Pittsburg State Uiversity.

Page1 / 4

PPT04_Implementing_Relationships - Implementing...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online