-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.java
408 lines (336 loc) · 14.5 KB
/
Admin.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
package mangohotel;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
class Info
{
String fname;
String lname;
String sex;
String place;
int age;
int days;
String book;
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public String getBook() {
return book;
}
public void setBook(String book) {
this.book = book;
}
}
class Setting
{
void display(Info f)
{
System.out.println(" ");
System.out.println(" ");
System.out.println("First Name: "+f.getFname());
System.out.println("Last Name: "+f.getLname());
System.out.println("Sex: "+f.getSex());
System.out.println("Place: "+f.getPlace());
System.out.println("Age: "+f.getAge());
System.out.println("Days: "+f.getDays());
System.out.println("Confirmation:"+f.getBook());
System.out.println(" ");
System.out.println(" ");
}
}
public class Admin {
private static boolean MainMenu = true;
private static boolean SubMenu = true;
static
{
System.out.println(" ");
System.out.println(" Mango Hotel");
System.out.println("🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴🌴");
System.out.println("➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻➻");
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println(" ");
System.out.println(" ");
System.out.print("Enter First Name: ");
String fname=sc.nextLine();
System.out.println(" ");
System.out.print("Enter Your Last Name: ");
String lname=sc.nextLine();
System.out.println(" ");
System.out.print("Enter Your Gender: ");
String sex=sc.next();
System.out.println(" ");
System.out.print("Enter Your Place: ");
String place=sc.next();
System.out.println(" ");
System.out.print("Enter your Age: ");
int age=sc.nextInt();
System.out.println(" ");
System.out.print("Total Booking Days: ");
int days=sc.nextInt();
System.out.println(" ");
System.out.print("Booking Confirmation: ");
String book=sc.next();
Info f=new Info();
f.setFname(fname);
f.setLname(lname);
f.setSex(sex);
f.setPlace(place);
f.setAge(age);
f.setDays(days);
f.setBook(book);
Setting s=new Setting();
s.display(f);
Scanner input = new Scanner(System.in);
Room[] myHotel = new Room[10];
myHotel[0] = new Room();
myHotel[1] = new Room();
myHotel[2] = new Room();
myHotel[3] = new Room();
myHotel[4] = new Room();
myHotel[5] = new Room();
myHotel[6] = new Room();
myHotel[7] = new Room();
myHotel[8] = new Room();
myHotel[9] = new Room();
int roomNum = 0;
initialise(myHotel);
while (MainMenu)
{
while (SubMenu)
{
System.out.println(" ");
System.out.println(" Welcome to our Mango Hotel Program");
System.out.println("🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏");
System.out.println("Select the options.");
System.out.println("A: Book A New Room ");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("E: Display Empty Rooms ");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("V: View all Rooms.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("D: Delete customer from room.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("F: Find room from customer name.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺");
System.out.println("S: Store program data in to file.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("L: Load program data from file.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println("O: View rooms Ordered alphabetically by name.");
System.out.println("🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺 ");
System.out.println(" ");
System.out.println(" ");
String Selection = input.next();
Selection = Selection.toUpperCase();
switch (Selection)
{
case "A":
BookARoom(myHotel, roomNum);
break;
case "E":
CheckIfEmpty(myHotel);
break;
case "V":
ViewAllRooms(myHotel);
break;
case "D":
DeleteCustomerFromRoom(myHotel, roomNum);
break;
case "F":
FindRoomFromCustomerName(myHotel);
break;
case "S":
StoreProgramDataInToFile(myHotel);
break;
case "L":
LoadProgramDataFromFile(myHotel);
break;
case "O":
ViewRoomsOrderedAlphabeticallyByName(myHotel);
break;
default:
System.out.println("Invalid Selection");
break;
}
System.out.println("👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉");
System.out.println(" ");
System.out.println("Would you like to Select another Option\n1 ) Yes\n2 ) No");
System.out.println("---------------------------------------------------------");
System.out.println("__________________________________________________________");
if (input.nextInt() == 1)
{
SubMenu = true;
} else
{
SubMenu = false;
}
}
SubMenu = true;
System.out.println("👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉👉");
System.out.println(" ");
System.out.println("Would You Like To Continue With The Program\n1 ) Yes\n2 ) No");
System.out.println("-------------------------------------------------------------");
System.out.println("______________________________________________________________");
if (input.nextInt() == 1)
{
MainMenu = true;
} else
{
System.out.println("");
System.exit(0);
}
}
}
private static void initialise(Room[] myHotel)
{
for (int x = 0; x < myHotel.length; x++)
{
myHotel[x].setName("nobody");
}
}
private static void CheckIfEmpty(Room[] myHotel) {
for (int x = 0; x < myHotel.length; x++)
{
if (myHotel[x].getName().equals("nobody")) {
System.out.println("room " + (x + 1) + " is empty");
}
}
}
private static void BookARoom(Room[] myHotel, int roomNum)
{
String roomName;
Scanner input = new Scanner(System.in);
System.out.println("Enter room number (1-10):");
roomNum = input.nextInt() - 1;
System.out.println("Enter name for room " + (roomNum + 1) + " :");
roomName = input.next();
myHotel[roomNum].setName(roomName);
}
private static void ViewAllRooms(Room[] myHotel)
{
for (int x = 0; x < myHotel.length; x++)
{
System.out.println("room " + (x + 1) + " occupied by " + myHotel[x].getName());
}
}
private static void DeleteCustomerFromRoom(Room[] myHotel, int roomNum)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter room number to delete(1-10):");
roomNum = input.nextInt() - 1;
myHotel[roomNum].setName("nobody");
System.out.println("Entery Deleted :)");
}
private static void FindRoomFromCustomerName(Room[] myHotel)
{
Scanner input = new Scanner(System.in);
String roomName;
System.out.println("Enter name to Search for:");
roomName = input.next();
int x;
boolean Checker = false;
for (x = 0; x < myHotel.length; x++)
{
if (roomName.equals(myHotel[x].getName()))
{
System.out.println("The Account That Matches That name is Account number " + x);
Checker = true;
}
}
if (Checker == false)
{
System.out.println("There are no Rooms Booked with that name\n(make sure you've used the correct CAP's)");
}
}
private static void StoreProgramDataInToFile(Room[] myHotel) throws IOException
{
try (PrintWriter out = new PrintWriter(new FileWriter(""))) {
int x;
for (x = 0; x < myHotel.length; x++) {
out.println("Name and Room number is: " + myHotel[x].getName() + "at: " + x);
}
}
System.out.println("All Room Names have been Saved.");
}
private static void LoadProgramDataFromFile(Room[] myHotel) throws IOException
{
FileInputStream fs = new FileInputStream(" ");
BufferedReader br = new BufferedReader(new InputStreamReader(fs));
for (int i = 0; i < myHotel.length; i++) {
myHotel[i].setName(br.readLine());
}
}
private static void ViewRoomsOrderedAlphabeticallyByName(Room[] myHotel)
{
String[] myStrArray = new String[myHotel.length];
for (int i = 0; i < myHotel.length; i++)
{
myStrArray[i] = myHotel[1].getName();
}
Arrays.sort(myStrArray);
for (int a = 0; a < myStrArray.length; a++)
{
System.out.println(myStrArray[a]);
}
}
public static class Room
{
//protected String mainName;
private String mainName;
int guestsInRoom;
public Room()
{
mainName = "k";
}
public void setName(String aName)
{
// System.out.println("add name class method ");
mainName = aName;
}
public String getName()
{
return mainName;
}
}
}