-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuOption.java
More file actions
38 lines (29 loc) · 951 Bytes
/
MenuOption.java
File metadata and controls
38 lines (29 loc) · 951 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
package runningShop;
public enum MenuOption{
EXIT(0, "Exit"),
LIST_PRODUCTS(1, "List Products"),
BUY_PRODUCT(2, "Buy Product"),
FIND_PRODUCT(3, "Find Product"),
SHOW_CART(4, "Show Cart"),
CHECKOUT(5, "Checkout");
private int id;
private String displayValue;
MenuOption(int id, String displayValue){
this.id = id;
this.displayValue = displayValue;
}
public int getId(){
return this.id;
}
public String getDisplayValue(){
return this.displayValue;
}
public static MenuOption fromOptionId(int optionId){
for(MenuOption option: MenuOption.values()){
if (option.id == optionId) {
return option;
}
}
throw new IllegalArgumentException(String.format("Menu option id %d is not an available option.", optionId));
}
}