import org.junit.Test;
public class Demo2 {
@Test
public void test(){
print(Grade.B);
}
public void print(Grade g){
String value=g.localValue();
System.out.println(value);
}
enum Grade{
A("100-90"){
public String localValue(){
return "优";
}
},
B("89-80"){
public String localValue(){
return "良";
}
},
C("79-70"){
public String localValue(){
return "一般";
}
},
D("69-60"){
public String localValue(){
return "及格";
}
},
E("59-0"){
public String localValue(){
return "差";
}
};
private String value;
//定义私有构造方法
private Grade(String value){
this.value=value;
}
public String getValue(){
return this.value;
}
public abstract String localValue();
}
}