80 likes | 104 Views
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
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