Composition & Enumerations A. COMPOSITION Composition adalah dimana hubungan suatu object bergantung dengan objek lainnya. Berikut ini program class Date, class Employee dan class EmployeeTest. Source Code : Class Date // Fig. 8.7: Date.java // Date class declaration. public class Date { private int month; private int day; private int year; private static final int[] daysPerMonth = //days in each month {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //contruktor : call checkMonth to confirm proper value for month; //call checkDay to confirm proper value for day public Date (int theMonth, int theDay, int theYear) { month = checkMonth(theMonth); year = theYear; day = checkDay(theDay); System.out.printf ("Date object constructor for date %s\n", this); } //utility method to confirm proper month value private int checkMon...
Komentar
Posting Komentar