1
2public class EnumTest {
3 Day day;
4
5 public EnumTest(Day day) {
6 this.day = day;
7 }
8
9 public void tellItLikeItIs() {
10 switch (day) {
11 case MONDAY:
12 System.out.println("Mondays are bad.");
13 break;
14
15 case FRIDAY:
16 System.out.println("Fridays are better.");
17 break;
18
19 case SATURDAY: case SUNDAY:
20 System.out.println("Weekends are best.");
21 break;
22
23 default:
24 System.out.println("Midweek days are so-so.");
25 break;
26 }
27 }
28
29 public static void main(String[] args) {
30 EnumTest firstDay = new EnumTest(Day.MONDAY);
31 firstDay.tellItLikeItIs();
32 EnumTest thirdDay = new EnumTest(Day.WEDNESDAY);
33 thirdDay.tellItLikeItIs();
34 EnumTest fifthDay = new EnumTest(Day.FRIDAY);
35 fifthDay.tellItLikeItIs();
36 EnumTest sixthDay = new EnumTest(Day.SATURDAY);
37 sixthDay.tellItLikeItIs();
38 EnumTest seventhDay = new EnumTest(Day.SUNDAY);
39 seventhDay.tellItLikeItIs();
40 }
41}
42
1
2public enum Day {
3 SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
4 THURSDAY, FRIDAY, SATURDAY
5}
6