enum Weekday{
MONDAAY ,
TUESDAY ,
WEDNESDAY,
THURSDAY ,
FRIDAY ,
SATURDAY ,
SUNDAY
//
}
/**
{
private Weekday(){}
public static final Weekday MONDAAY = new Weekday();
public static final Weekday TUESDAY = new Weekday();
public static final Weekday WEDNESDAY = new Weekday();
public static final Weekday THURSDAY = new Weekday();
public static final Weekday FRIDAY = new Weekday();
public static final Weekday SATURDAY = new Weekday();
public static final Weekday SUNDAY = new Weekday();
}*/
class Employee
{
private Weekday restday; //定义一周的哪一天休息
public Weekday getRestday() {
return restday;
}
public void setRestday(Weekday restday){
this.restday = restday;
}
}
class EnumDemo
{
public static void main(String[] args)
{
//创建一个员工对象,并设置哪一天休息。
Employee employee = new Employee();
employee.setRestday(Weekday.FRIDAY);
Weekday weekday = employee.getRestday();
if (weekday == Weekday.SATURDAY || weekday == Weekday.SUNDAY)
{
System.out.println("周末休息");
}else{
System.out.println("工作日休息");
}
}
}