-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.java
More file actions
42 lines (36 loc) · 1.17 KB
/
Menu.java
File metadata and controls
42 lines (36 loc) · 1.17 KB
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
package cafeteria;
class Menu {
private String[] items = {
"Injera - ETB 30", "Doro Wat - ETB 120", "Kitfo - ETB 150",
"Tibs - ETB 100", "Shiro - ETB 50", "Sambusa - ETB 20",
"Asa - ETB 80", "T'ej - ETB 40"
};
private double[] prices = {30, 120, 150, 100, 50, 20, 80, 40};
private String menuType;
private String lastUpdated;
public Menu(String menuType, String lastUpdated) {
this.menuType = menuType;
this.lastUpdated = lastUpdated;
}
public void showMenu() {
System.out.println("Menu (" + menuType + "):");
for (int i = 0; i < items.length; i++) {
System.out.println(items[i]);
}
System.out.println("********************************************");
}
public double getItemPrice(String item) throws Exception {
for (int i = 0; i < items.length; i++) {
if (items[i].contains(item)) {
return prices[i];
}
}
throw new Exception("Item not found in the menu.");
}
public String getMenuType() {
return menuType;
}
public String getLastUpdated() {
return lastUpdated;
}
}