80 likes | 109 Views
Learn about composition in Java programming, where classes can have references to objects of other classes as members. This course covers date validation, employee references, and implicit method calls.
E N D
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-arelationship • 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 • (3 of 3) Check if the day is February 29 on a leap year
Outline Employee contains references to two Date objects • Employee.java 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