-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy pathMain.java
More file actions
47 lines (38 loc) · 1.64 KB
/
Main.java
File metadata and controls
47 lines (38 loc) · 1.64 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
42
43
44
45
46
47
package org.launchcode;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Initializing menu items
ArrayList<MenuItem> menuItems = new ArrayList<>();
menuItems.add(new MenuItem(5.99, "Bruschetta", Category.APPETIZER, true));
menuItems.add(new MenuItem(15.99, "Chicken Alfredo", Category.MAIN_COURSE, false));
menuItems.add(new MenuItem(7.99, "Brownie", Category.DESSERT, false));
// Using the provided constructor to initialize the Menu
Menu menu = new Menu(new Date(), menuItems);
Scanner scanner = new Scanner(System.in);
String choice;
do {
System.out.println("Do you want to print a single item, all menu items, or exit? (Enter 'single', 'all' or '0' to exit)");
choice = scanner.nextLine().toLowerCase().trim();
switch(choice) {
case "single":
System.out.println("Please enter the beginning of the item description:");
String startOfDescription = scanner.nextLine().toLowerCase().trim();
menu.printItemsWithDescription(startOfDescription);
break;
case "all":
menu.printMenu();
break;
case "0":
System.out.println("Exiting the program...");
break;
default:
System.out.println("Invalid choice.");
break;
}
} while (!"0".equals(choice));
scanner.close();
}
}