Design a program using Java NetBeans (Console application). With the following enum class: public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } Create a second class called enumDayMood with a void method call telDayMood (). This method contain a switch case as follows
import javax.swing.JOptionPane;
enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
class enumDayMood {
void telDayMood(Day day) {
switch (day) {
case MONDAY:
JOptionPane.showMessageDialog(null, "Mondays are bad.");
break;
case FRIDAY:
JOptionPane.showMessageDialog(null, "Fridays are better.");
break;
case SATURDAY:
case SUNDAY:
JOptionPane.showMessageDialog(null, "Weekends are best.");
break;
default:
JOptionPane.showMessageDialog(null, "Midweek days are so-so.");
break;
}
}
}
public class DayMoodApp {
public static void main(String[] args) {
enumDayMood enumDayMood=new enumDayMood();
enumDayMood.telDayMood(Day.SATURDAY);
enumDayMood.telDayMood(Day.FRIDAY);
enumDayMood.telDayMood(Day.TUESDAY);
enumDayMood.telDayMood(Day.MONDAY);
}
}
Comments
Leave a comment