[置顶] 请编写一个关于星期几的枚举WeekDay,要求: 枚举值:Mon,Tue,Wed,Thu,Fri,Sat,Sun 该枚举要有一个方法,调用该方法返回中文格式的星期。

package com.week.base;


public class Demo1 {

/**
* @param args
*/
public static void main(String[] args) {

Week s=new Week();
s.setName("今天");
s.setGrade(Grade.Mon);


  String str=Grade.Mon.getValue();
  String str1=Grade.Mon.toLocalGrade();
  System.out.println(str+"...."+str1);

}

}



package com.week.base;

public class Week {

private String name;
private Grade grade;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Grade getGrade() {
return grade;
}
public void setGrade(Grade grade) {
this.grade = grade;
}




}

enum Grade{
Mon("Monday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期一";
}
},
Tue("Tuesday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期二";
}
},
Wed("Wednesday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期三";
}
},
Thu("Thursday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期四";
}
},
Fri("Friday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期五";
}
},
Sat("Saturday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期六";
}
},
Sun("Sunday") {
@Override
public String toLocalGrade() {
// TODO Auto-generated method stub
return "星期日";
}
}, ;

private String value;

private Grade(String value){
this.value=value;
}

public String getValue() {
return value;
}

public abstract String toLocalGrade();

}

你可能感兴趣的:(String,Class,sun)