package cn.first.enum1;
import org.junit.Test;
public class Demo1 {
@Test
public void Test(){
print(Grade.B);
}
public void print(Grade g){//A B C D E
System.out.println(g.getValue());
}
}
/*class Grade{
private Grade(){};
public static final Grade A = new Grade();
public static final Grade B = new Grade();
public static final Grade C = new Grade();
public static final Grade D = new Grade();
public static final Grade E = new Grade();
}*/
enum Grade{//class A 100~90 B 89~80 C 79~70 D 69~60 E 59~0
A("100~90"),B("89~80"),C("79~70"),D("69~60"),E("59~0");//Object
private String value;//封装每个对象对应的分数
private Grade(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
import org.junit.Test;
public class Demo1 {
@Test
public void Test(){
print(Grade.B);
}
public void print(Grade g){//A B C D E
System.out.println(g.getValue());
}
}
/*class Grade{
private Grade(){};
public static final Grade A = new Grade();
public static final Grade B = new Grade();
public static final Grade C = new Grade();
public static final Grade D = new Grade();
public static final Grade E = new Grade();
}*/
enum Grade{//class A 100~90 B 89~80 C 79~70 D 69~60 E 59~0
A("100~90"),B("89~80"),C("79~70"),D("69~60"),E("59~0");//Object
private String value;//封装每个对象对应的分数
private Grade(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}