-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonth.java
More file actions
34 lines (30 loc) · 740 Bytes
/
Month.java
File metadata and controls
34 lines (30 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package newLessons.lessonTen;
public enum Month {
JANUARY(31),
FEBRUARY(28),
MARCH(31),
APRIL(30),
MAY(31),
JUNE(30),
JULY(31),
AUGUST(31),
SEPTEMBER(30),
OCTOBER(31),
NOVEMBER(30),
DECEMBER(31);
private int maxAmountOfDays;
private Month(int maxDays) {
this.maxAmountOfDays = maxDays;
}
// Notice that I could use the private scope modifier since the Person class and the Month class were inside the same class.
// private really means that it is private only within the file.
//
// Now notice that I have to use public as they are no longer in the same class.
public int fixDay(int dayToFix) {
if (dayToFix > this.maxAmountOfDays) {
return this.maxAmountOfDays;
} else {
return dayToFix;
}
}
}