-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.java
137 lines (124 loc) · 3.96 KB
/
Menu.java
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import java.util.Scanner;
public class Menu {
private ParticipantsUtility participantsUtility;
private EventsUtility eventsUtility;
Menu(ParticipantsUtility participantsUtility, EventsUtility eventsUtility) {
this.participantsUtility = participantsUtility;
this.eventsUtility = eventsUtility;
}
public void runMainMenu() {
Scanner sc = new Scanner(System.in);
mainMenu(sc);
sc.close();
}
private void mainMenu(Scanner sc) {
int option;
System.out.println("1. Events");
System.out.println("2. Participants");
System.out.println("3. Exit");
System.out.print("Select an option: ");
option = sc.nextInt();
boolean shouldExit = false;
if (option == 1)
eventsMenu(sc);
else if (option == 2)
participantsMenu(sc);
else if (option == 3)
shouldExit = true;
else
System.out.println("Wrong option!");
System.out.println();
if (shouldExit)
return;
mainMenu(sc);
}
private void eventsMenu(Scanner sc) {
int option;
System.out.println("1. Create event");
System.out.println("2. See event");
System.out.println("3. Update event");
System.out.println("4. Delete event");
System.out.println("5. Display all events");
System.out.println("6. Back");
System.out.print("Select an option: ");
option = sc.nextInt();
boolean shouldExit = false;
switch (option) {
case 1:
eventsUtility.createEvent();
break;
case 2:
eventsUtility.getEvent();
break;
case 3:
eventsUtility.updateEvent();
break;
case 4:
eventsUtility.deleteEvent();
break;
case 5:
eventsUtility.getAllEvents();
break;
case 6:
shouldExit = true;
break;
default:
// Wrong option
System.out.println("Wrong option!");
break;
}
System.out.println();
if (shouldExit)
return;
eventsMenu(sc);
}
private void participantsMenu(Scanner sc) {
int option;
System.out.println("1. Create participant");
System.out.println("2. See participant");
System.out.println("3. Update participant");
System.out.println("4. Delete participant");
System.out.println("5. register participant for event");
System.out.println("6. Display all participants");
System.out.println("7. Back");
System.out.print("Select an option: ");
option = sc.nextInt();
boolean shouldExit = false;
switch (option) {
case 1:
// Create participant
participantsUtility.createParticipant();
break;
case 2:
// Read participant
participantsUtility.getParticipant();
break;
case 3:
// Update participant
participantsUtility.updateParticipant();
break;
case 4:
// Delete participant
participantsUtility.deleteParticipant();
break;
case 5:
// Register
participantsUtility.registerParticipanttoEvent();
break;
case 6:
participantsUtility.getAllParticipants();
break;
case 7:
shouldExit = true;
break;
default:
// Wrong option
System.out.println("Wrong option!");
break;
}
System.out.println();
if (shouldExit)
return;
participantsMenu(sc);
}
}