June 2017
Beginner
1296 pages
69h 23m
English
... out-of-range for the specified month and year");
25 }
26
27 // check for leap year if month is 2 and day is 29
28 if (month == 2 && day == 29 && !(year % 400 == 0 ||
29 (year % 4 == 0 && year % 100 != 0))) {
30 throw new IllegalArgumentException("day (" + day +
31 ") out-of-range for the specified month and year");
32 }
33
34 this.month = month;
35 this.day = day;
36 this.year = year;
37
38 System.out.printf("Date object constructor for date %s%n", this);
39 }
40
41 // return a String of the form month/day/year
42 public String toString() {
43 return String.format("%d/%d/%d", month, day, year);
44 }
45 }
Date class declaration.
EmployeeClass Employee (Fig. 8.8) has reference-type instance variables firstName (String), last-Name (String), birthDate ...
Read now
Unlock full access