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();
}
转载于:https://www.cnblogs.com/zgl521/archive/2012/09/17/3057733.html