-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
85 lines (80 loc) · 2.7 KB
/
Copy pathMain.java
File metadata and controls
85 lines (80 loc) · 2.7 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Scanner;
public class Main {
static List<Reservation> Reservations = new ArrayList<>();
static ReservationSystem a = new ReservationSystem(Reservations);
/**
* Method Name: Main
* Purpose: Call displayMenu
* @param args
*/
public static void main(String[] args) {
displayMenu();
}
/**
* Method Name: displayMenu
* Purpose: Display the menu to the user and get user input to call desired method
*/
public static void displayMenu() {
Scanner sc = new Scanner(System.in);
final int END = 7;
int choice = 0;
try {
while (choice > 7 || choice < 1) {
System.out.println("Welcome to the Hotel Reservation System! Please select and option.");
System.out.println("1) Upload Reservations");
System.out.println("2) New Reservation");
System.out.println("3) Update Reservation");
System.out.println("4) View All Existing Reservations");
System.out.println("5) Find Reservation");
System.out.println("6) Download Statistics");
System.out.println("7) EXIT");
choice = sc.nextInt();
if (choice == END) {
return;
}
if (choice > 7 || choice < 1) {
System.err.println("Not a valid option, please try again.");
}
}
}
catch (InputMismatchException e) {
System.err.println("Not a valid option, please try again.");
displayMenu();
}
switch (choice) {
case 1:
a.uploadReservations(sc);
System.out.println("\n");
displayMenu();
break;
case 2:
a.addReservation(sc);
System.out.println("\n");
displayMenu();
break;
case 3:
a.updateReservation(sc);
System.out.println("\n");
displayMenu();
break;
case 4:
a.viewReservations();
System.out.println("\n");
displayMenu();
break;
case 5:
a.findReservation();
System.out.println("\n");
displayMenu();
break;
case 6:
a.downloadReservations();
System.out.println("\n");
displayMenu();
break;
}
}
}