Skip to content

Commit 8e373e7

Browse files
committed
elevated enums 🪁
1 parent 09ce102 commit 8e373e7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

EnumaratedTypes/Example.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @author viktorvoltz
3+
*/
4+
public enum Example {
5+
WALK("press to walk"),
6+
RUN("press to run"),
7+
JUMP("press to jump"),
8+
SIT("press to sit");
9+
10+
private String description;
11+
12+
private Example(String description){
13+
this.description = description;
14+
}
15+
16+
@Override
17+
public String toString() {
18+
String id = name(); //name from java.lang.Enum.name()
19+
return id;
20+
}
21+
22+
public String getDescription(){
23+
return description;
24+
}
25+
26+
public static void main(String[] args) {
27+
for(Example e : Example.values()){
28+
System.out.println(e + ": " + e.getDescription());
29+
}
30+
}
31+
}
32+
/*
33+
WALK: press to walk
34+
RUN: press to run
35+
JUMP: press to jump
36+
SIT: press to sit
37+
*/

0 commit comments

Comments
 (0)