-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientMenu.java
More file actions
289 lines (226 loc) · 11.2 KB
/
ClientMenu.java
File metadata and controls
289 lines (226 loc) · 11.2 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
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
package com.company;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Objects;
public class ClientMenu {
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> rentals= new HashMap<String,String>();
protected HashMap<String,Rentable> rentalsV2= new HashMap<String,Rentable>();
protected String usernam;
protected String howner;
protected HashMap<String,String> rentcancel= new HashMap<String,String>();
protected HashMap<String, String> messages = new HashMap<String, String>();
/**
* <p>
* This is the main menu/choice menu for the client 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 asvus, aausers, arentals, auser, arented, arentalsV2,rc,msg
* @return -
* @see -
* @author
*/
public void clientMenu(String asvus,HashMap<String,String> aausers,HashMap<String,String>arentals,
HashMap<String,User>auser,HashMap<String,String>arented,
HashMap<String,Rentable>arentalsV2,HashMap<String,String>rc,
HashMap<String,String>msg) {
//start of ui
System.out.println("---------------------");
System.out.println("press 1 to search rooms");
System.out.println("press 2 to reserve a room");
System.out.println("press 3 to cancel a reservation");
System.out.println("press 4 to see your profile");
System.out.println("press 5 to see messages");
System.out.println("press any other number to close the program");
System.out.println("---------------------");
//end of ui
this.usernam=asvus;
this.ausers=aausers;
this.rentals=arentals;
this.user=auser;
this.rented=arented;
this.rentalsV2=arentalsV2;
this.rentcancel=rc;
this.messages=msg;
Scanner oo2 = new Scanner(System.in);
int op2 = oo2.nextInt();
switch (op2) {
case 4: { //press 1 to see your profile
for (Map.Entry<String, User> e : user.entrySet()) {
if (Objects.equals(usernam, e.getKey())) {
Client u1= new Client();
u1.profile(e.getValue());
}
}
//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 press 2");
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) {
ClientMenu dummy1 = new ClientMenu();
dummy1.clientMenu(this.usernam, this.ausers, this.rentals, this.user, this.rented,
this.rentalsV2, this.rentcancel, this.messages);
}
else
{
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
//end of loop
//break;
}
case 2:{ //press 2 to reserve a room
System.out.println("Rent room/home info:");
System.out.println("Unique key(numbers/letters):");
Scanner sc1 = new Scanner(System.in);
String key = sc1.nextLine();
rented.put(key,usernam);
for (Map.Entry<String, String> e : rentals.entrySet()) {
if (Objects.equals(key, e.getKey())) {
this.howner = e.getValue();
}
}
rentals.remove(key);
System.out.println("room successfully rented!");
//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 press 2");
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) {
ClientMenu dummy1 = new ClientMenu();
dummy1.clientMenu(this.usernam, this.ausers, this.rentals, this.user, this.rented,
this.rentalsV2, this.rentcancel, this.messages);
}
else
{
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
//end of loop
//break;
}
case 3:{ //press 3 to cancel a reservation
System.out.println("Cancel room info:");
System.out.println("Unique key(numbers/letters):");
Scanner sc1 = new Scanner(System.in);
String key = sc1.nextLine();
for (Map.Entry<String, String> e : rented.entrySet()) {
if (Objects.equals(key, e.getKey()) && Objects.equals(usernam, e.getValue())) {
rented.remove(key); //🎮
rentcancel.put(key,howner);
rentals.put(key,howner);
}
}
System.out.println("rent canceled successfully");
//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 press 2");
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) {
ClientMenu dummy1 = new ClientMenu();
dummy1.clientMenu(this.usernam, this.ausers, this.rentals, this.user, this.rented,
this.rentalsV2, this.rentcancel, this.messages);
}
else
{
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
//end of loop
//break;
}
case 1:{ //press 4 to search rooms
for (Map.Entry<String, Rentable> e : rentalsV2.entrySet()) {
for(Map.Entry<String, String> j : rented.entrySet() ) {
if (Objects.equals(e.getKey(), j.getKey())) {
System.out.println("↓↓ Rented ↓↓");
Rentable u3= new Rentable();
u3.display(e.getValue());
}
}
System.out.println("↓↓ Available ↓↓");
Rentable u3= new Rentable();
u3.display(e.getValue());
}
//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 press 2");
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) {
ClientMenu dummy1 = new ClientMenu();
dummy1.clientMenu(this.usernam, this.ausers, this.rentals, this.user, this.rented,
this.rentalsV2, this.rentcancel, this.messages);
}
else
{
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
//end of loop
}
case 5:{ //press 5 to see messages
System.out.println("Messages:");
for (Map.Entry<String, String> e : messages.entrySet()) {
if (Objects.equals(usernam, e.getValue())) {
System.out.println("Sender: Admin," + " Receiver: " + e.getValue()
+ ", Message: " + e.getKey());
}
}
//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 press 2");
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) {
ClientMenu dummy1 = new ClientMenu();
dummy1.clientMenu(this.usernam, this.ausers, this.rentals, this.user, this.rented,
this.rentalsV2, this.rentcancel, this.messages);
}
else
{
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
//end of loop
//break;
}
default :{ //press any to close the program
System.out.println("Thank you for using our sofware "+usernam);
System.exit(404);
}
}
}
}