-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminMenu.java
302 lines (242 loc) · 11.2 KB
/
AdminMenu.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
package com.company;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
public class AdminMenu {
protected HashMap<String, String> ausers = new HashMap<String, String>();
protected HashMap<String, String> rented = new HashMap<String, String>();
protected HashMap<String, User> user = new HashMap<String, User>();
protected HashMap<String, String> messages = new HashMap<String, String>();
protected HashMap<String, String> roles = new HashMap<String, String>();
//see users
public JMenu guiOp1(HashMap<String,String> us)
{
this.ausers=us;
//this.roles=rl;
JMenu submenu = new JMenu("See users");
for (String i : ausers.keySet()) {
//System.out.println(i);
JMenuItem submenuItem1 = new JMenuItem(i);
submenu.add(submenuItem1);
}
return submenu;
}
//search users
public void guiOp2()
{
}
//see reservations
public void guiOp3()
{
}
//search reservation
public void guiOp4()
{
}
//send message
public void guiOp5()
{
}
/**
* <p>
* This is the main menu/choice menu for the admin it is in a diffrent class
* from the main to make the ui and the debuging easier it gets all the parameters
* from the main.java and it prints what it need to in the command line/app
*<br>
* @param aausers, arentals, auser, msg
* @return -
* @see -
* @author
*/
public void adminMenu(HashMap<String,String> aausers,HashMap<String,String>arented,
HashMap<String,User>auser, HashMap<String,String>msg) {
//start of ui
System.out.println("---------------------");
System.out.println("press 1 to see all users");
System.out.println("press 2 to search a user");
System.out.println("press 3 to see reservations");
System.out.println("press 4 to search a reservation");
System.out.println("press 5 to send a message to a user");
System.out.println("press any other number to close the program");
System.out.println("---------------------");
//end of ui
this.ausers = aausers;
this.rented = arented;
this.user = auser;
this.messages=msg;
Scanner oo2 = new Scanner(System.in);
int op2 = oo2.nextInt();
switch (op2) {
case 1: { //press 1 to see all users
for (String i : ausers.keySet()) {
System.out.println(i);
}
//oh sorry i forgot my phone 📱
//here
//choice for loop to the main menu or exit
//System.out.println("If you want to return to the main menu press 1. If you want to" +
// "close the program press2");
System.out.println("---------------------");
System.out.println("If you want to return to the main menu press 1");
System.out.println("If you want to close the program press2");
System.out.println("---------------------");
Scanner e2 = new Scanner(System.in);
int ep2 = e2.nextInt();
if(ep2==1) {
AdminMenu dummy2 = new AdminMenu();
dummy2.adminMenu( this.ausers, this.rented, this.user, this.messages);
}
else
{
System.out.println("Thank you for working on our software ");
System.exit(404);
}
//end of loop
//break;
}
case 2: { //press 2 to search a user
boolean found = false;
System.out.println("write the username of the user:");
Scanner sc1 = new Scanner(System.in);
String ser1 = sc1.nextLine();
for (String i : ausers.keySet()) {
if (Objects.equals(i, ser1)) {
System.out.println("This user exists with the username");
System.out.println(i);
found = true;
break;
}
}
if (found == false)
System.out.println("this user doesnt exist");
//here
//choice for loop to the main menu or exit
//System.out.println("If you want to return to the main menu press 1. If you want to " +
//"close the program press2");
System.out.println("---------------------");
System.out.println("If you want to return to the main menu press 1");
System.out.println("If you want to close the program press2");
System.out.println("---------------------");
Scanner e2 = new Scanner(System.in);
int ep2 = e2.nextInt();
if(ep2==1) {
AdminMenu dummy2 = new AdminMenu();
dummy2.adminMenu( this.ausers, this.rented, this.user, this.messages);
}
else
{
System.out.println("Thank you for working on our software ");
System.exit(404);
}
//end of loop
//break;
}
case 3: { //press 3 to see reservations
for (String i : rented.keySet()) {
if(i=="") // i need to find what it saves in a null hashmap
{//who cares if it is null it doesnt return anything if it
//has objs it prints them sooo
System.out.println("none");
break;
}
System.out.println("");
System.out.println(i);
}
//here
//choice for loop to the main menu or exit
//System.out.println("If you want to return to the main menu press 1. If you want to" +
//"close the program press2");
System.out.println("---------------------");
System.out.println("If you want to return to the main menu press 1");
System.out.println("If you want to close the program press2");
System.out.println("---------------------");
Scanner e2 = new Scanner(System.in);
int ep2 = e2.nextInt();
if(ep2==1) {
AdminMenu dummy2 = new AdminMenu();
dummy2.adminMenu( this.ausers, this.rented, this.user, this.messages);
}
else
{
System.out.println("Thank you for working on our software ");
System.exit(404);
}
//end of loop
//break;
}
case 4: { //press 4 to search a reservation
boolean found = false;
System.out.println("write the name of the room:");
Scanner sc1 = new Scanner(System.in);
String ser1 = sc1.nextLine();
for (String i : rented.keySet()) {
if (Objects.equals(i, ser1)) {
System.out.println("It is rented");
found = true;
break;
}
}
if (found == false)
System.out.println("this room isnt rented or it doesnt exist");
//here
//choice for loop to the main menu or exit
// System.out.println("If you want to return to the main menu press 1. If you want to" +
// "close the program press2");
System.out.println("---------------------");
System.out.println("If you want to return to the main menu press 1");
System.out.println("If you want to close the program press2");
System.out.println("---------------------");
Scanner e2 = new Scanner(System.in);
int ep2 = e2.nextInt();
if(ep2==1) {
AdminMenu dummy2 = new AdminMenu();
dummy2.adminMenu( this.ausers, this.rented, this.user, this.messages);
}
else
{
System.out.println("Thank you for working on our software ");
System.exit(404);
}
//end of loop
//break;
}
case 5: { //press 5 to send a message to a user
System.out.println("Receiver:");
Scanner rec = new Scanner(System.in);
String receive = rec.nextLine();
System.out.println("Message:");
Scanner mssg = new Scanner(System.in);
String message = mssg.nextLine();
messages.put(message,receive);
System.out.println("Message successfully send to " +receive);
//here
//choice for loop to the main menu or exit
// System.out.println("If you want to return to the main menu press 1. If you want to" +
// "close the program press2");
System.out.println("---------------------");
System.out.println("If you want to return to the main menu press 1");
System.out.println("If you want to close the program press2");
System.out.println("---------------------");
Scanner e2 = new Scanner(System.in);
int ep2 = e2.nextInt();
if(ep2==1) {
AdminMenu dummy2 = new AdminMenu();
dummy2.adminMenu( this.ausers, this.rented, this.user, this.messages);
}
else
{
System.out.println("Thank you for working on our software ");
System.exit(404);
}
//end of loop
//break;
}
default :{ //press any to close the program
System.out.println("Thank you for working on our software ");
System.exit(404);
}
}
}
}