-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithAbctract.java
More file actions
61 lines (52 loc) · 986 Bytes
/
Copy pathWithAbctract.java
File metadata and controls
61 lines (52 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package myenum;
import org.junit.Test;
public class WithAbctract {
@Test
public void test(){
getValue(Grade.C);
}
public void getValue(Grade g){
System.out.println(g.localValue());
}
@Test
public void test2(){
System.out.println(Grade.A.name());
System.out.println(Grade.A.ordinal());
Grade g=Grade.valueOf("B");
System.out.println(g.value);
Grade grades[]=Grade.values();//get all of the elements in the enum
for(Grade gra:grades){
System.out.println(gra);
}
}
enum Grade{
A("85-100"){
public String localValue(){
return "ÓÅ";
}
},
B("70-85"){
public String localValue(){
return "Á¼";
}
},
C("60-70"){
public String localValue(){
return "ºÏ¸ñ";
}
},
D("0-60"){
public String localValue(){
return "²î";
}
};
private String value=null;
private Grade(String grade){
value=grade;
}
public String getGrade(){
return value;
}
public abstract String localValue();
}
}