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 E-mail: droberts@cs.iupui.edu
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.
Outline Date.java (1 of 3)
Outline Validates month value Date.java (2 of 3) Validates day value
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
Outline Employee.java Employee contains references to two Date objects Implicit calls to hireDate and birthDate’s toString methods
Outline EmployeeTest.java Create an Employee object Display the Employee object
Acknowledgements Deitel, Java How to Program