Download presentation
1
Object Oriented Programming using Java - Composition
Department of Computer and Information Science, School of Science, IUPUI Object Oriented Programming using Java - Composition Dale Roberts, Lecturer Computer Science, IUPUI
2
Composition Composition
A class can have references to objects of other classes as members Sometimes referred to as a has-a relationship One form of software reuse is composition, in which a class has as members references to objects of other classes.
3
Outline Date.java (1 of 3)
4
Outline Validates month value Date.java (2 of 3) Validates day value
5
Outline Date.java Check if the day is February 29 on a leap year
(3 of 3) Check if the day is February 29 on a leap year
6
Outline Employee.java Employee contains references to two Date objects
Implicit calls to hireDate and birthDate’s toString methods
7
Outline EmployeeTest.java Create an Employee object
Display the Employee object
8
Acknowledgements Deitel, Java How to Program
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.