-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuOptions.java
More file actions
32 lines (26 loc) · 870 Bytes
/
MenuOptions.java
File metadata and controls
32 lines (26 loc) · 870 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
package runningShop;
public enum MenuOptions {
EXIT_MENU(0, "Exit Menu"),
IS_EVEN(1, "Check to see if even or odd"),
PERFECT_SQUARE(2, "Check to see if number is a perfect square.");
private int id;
private String displayValue;
MenuOptions(int id, String displayValue){
this.id = id;
this.displayValue = displayValue;
}
public static MenuOptions fromOptionId(int optionId){
for(MenuOptions option: MenuOptions.values()){
if (option.id == optionId) {
return option;
}
}
throw new IllegalArgumentException(String.format("Menu option id %d is not an available option.", optionId));
}
public String getDisplayValue(){
return displayValue;
}
public int getId(){
return id;
}
}