-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotel_Reservation_System.java
More file actions
1055 lines (938 loc) · 43.3 KB
/
Hotel_Reservation_System.java
File metadata and controls
1055 lines (938 loc) · 43.3 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
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*Create a personal portfolio showcasing your skills,
projects, and resume. Use HTML for structure, CSS
for styling, and add a touch of JavaScript for
interactivity.
Hotel Reservation System
Build a hotel reservation system where users can
search for available rooms, make reservations, and view
booking details. Include features like room
categorization and payment processing. */
import java.util.*;
import java.time.LocalDate;
import java.time.Period;
// This class is specifically for Hotel sign in or register for customers.
class Hotel_SignUp_Login{
Scanner sc = new Scanner(System.in);
String userInput, passwordInput,choice;
private ArrayList<String> Cutomer_Username = new ArrayList<>();
private ArrayList<String> Customer_password = new ArrayList<>();
/**
*
* @param checkCondition
* @return
* This below function is used to check conditions for the whole users if user want to do osmething or not as per the request comes out.
*/
boolean checkCondition(String choice){
if(choice.equalsIgnoreCase("yes")||choice.equalsIgnoreCase("y")||choice.equalsIgnoreCase("ye")){
return true;
}
else{
return false;
}
}
//This below function used to store details of persons who sign up or register in the system.
private void addLoginDetails(String user_name, String pass){
this.Cutomer_Username.add(user_name);
this.Customer_password.add(pass);
}
/**
* @param displayMessage this will contain the message to be displayed on the terminal.
* @description This function will be used to display any message
**/
void printMessage(String displayMessage) {
System.out.println(displayMessage);
}
// This function below will be used to sign up and is the first step before you login.
public boolean signup(){
System.out.println("Enter the user_name.\nLength of username should be more than 8 characters.");
userInput = sc.nextLine();
while(userInput.length()<8) {
System.out.println("\nUsername should be at least 8 or more than 8 characters long.");
System.out.println("Enter the Username.");
userInput = sc.nextLine();
}
System.out.println();
System.out.println("Enter the password.");
System.out.println("Length of Password should be more than 8 characters long.");
passwordInput = sc.nextLine();
while(passwordInput.length()<8){
System.out.println("Password should be at least 8 or more than 8 characters long.");
System.out.println("Enter the password.");
passwordInput = sc.nextLine();
}
System.out.println();
System.out.println("Successfully Registered.");
System.out.println("Please enter the same details again when redirected to login page.");
System.out.println();
addLoginDetails(userInput, passwordInput);
if(login()){
return true;
}
else{
return false;
}
}
/*This below function is used to update your username and password in case the users fails to login. */
private boolean update_sign(){
for(int i=0;i<Customer_password.size();i++){
System.out.println("Enter the user_name.");
System.out.println("Length of username should be more than 8 characters.");
userInput = sc.nextLine();
System.out.println();
while(userInput.length()<8){
System.out.println("Username should be at least 8 or more than 8 characters long.");
System.out.println("Enter the UserName again.");
userInput = sc.nextLine();
}
System.out.println();
System.out.println("Enter the password.");
System.out.println("Length of password should be more than 8 characters.");
passwordInput = sc.nextLine();
System.out.println();
while(passwordInput.length()<8){
System.out.println("Password should be at least 9 characters long.");
System.out.println("Enter the password.");
passwordInput = sc.next();
}
System.out.println();
System.out.println("Successfully Registered New user and Password.");
System.out.println("Please enter the same details again when redireted to login page.");
System.out.println();
Cutomer_Username.set(i, userInput);
Customer_password.set(i, passwordInput);
addLoginDetails(userInput, passwordInput);
login();
break;
}
return true;
}
//This below function is used to log in first in the system.
public boolean login(){
int attempts =4;
System.out.println("Enter the user name.");
System.out.println("Length of Username should be more than 8 characters.");
userInput = sc.nextLine();
while(userInput.length()<8){
System.out.println("\nUsername should be at least 8 or more than 8 characters long");
System.out.println("Enter the username");
userInput = sc.nextLine();
}
System.out.println();
System.out.println("Enter the password");
System.out.println("Length of password should be more than 8 characters.");
passwordInput = sc.nextLine();
while(passwordInput.length()<8){
System.out.println("\nPassword should be at least 8 or more than 8 characters long");
System.out.println("Enter the password");
passwordInput = sc.nextLine();
sc.nextLine();
}
System.out.println();
if(Customer_password.isEmpty()&& Cutomer_Username.isEmpty()){
System.out.println("\nDear Customer, there is no user registered on this Id.");
System.out.println("If you want to signup.");
System.out.println("Please Tell Yes or no.");
choice= sc.nextLine();
System.out.println();
if(checkCondition(choice)){
if(signup())
return true;
}
else{
return false;
}
}
for (int i = 0; i < Cutomer_Username.size(); i++) {
if(Cutomer_Username.get(i).equals(userInput)&& Customer_password.get(i).equals(passwordInput)){
System.out.println("\nLogin Successfull Hooraayyyy!!\nWelcome to the Hotel Booking system.\n");
System.out.println("Please Do not share the username and password.");
System.out.println();
return true;
}
break;
}
while(attempts>0){
attempts--;
System.out.println("Wrong Input given.");
System.out.println("Only "+attempts+ " attempts left");
System.out.println();
System.out.println("Enter the user name.\nLength of Username should be more than 8 characters.");
userInput =sc.nextLine();
while(userInput.length()<8){
System.out.println("Username should be at least 8 or more than 8 characters long");
System.out.println("Enter the username");
userInput = sc.nextLine();
}
System.out.println();
System.out.println("Enter the password");
System.out.println("Length of password should be more than 8 characters.");
passwordInput = sc.nextLine();
while(passwordInput.length()<8){
System.out.println("Password should be at least 8 or more than 8 characters long");
System.out.println("Enter the password");
passwordInput = sc.nextLine();
}
for (int i = 0; i < Cutomer_Username.size(); i++) {
if(Cutomer_Username.get(i).equals(userInput)&& Customer_password.get(i).equals(passwordInput)){
System.out.println("\nLogin Successfull Hooraayyyy!!\nWelcome to the Hotel Booking system.\n");
System.out.println("Please Do not share the username and password.");
System.out.println();
return true;
}
break;
}
System.out.println();
if(attempts==1){
System.out.println("If you have forgotten the input do you want to change it.");
System.out.println("Please enter yes or no");
choice= sc.nextLine();
System.out.println();
if(checkCondition(choice)){
if(update_sign())
return true;
break;
}
else{
System.out.println("Terminating the program");
return false;
}
}
}
return true;
}
}
// This below class is for handling all the operations for ex data entered by user and it also inherits the login class.
class HotelBooking extends Hotel_SignUp_Login{
protected static Scanner sc = new Scanner(System.in);
protected static Random ra = new Random();
protected int total_room_remain;
protected int new_room_available;
private int room,days;
private List<Integer> rooms = new ArrayList<>();
String check_in,check_out,choice;
protected double newprice_ac;
protected double newprice_non_ac;
protected Double updated_price;
private Set<Integer> uniqueRoomNumbers = new HashSet<>();
private List<String> Room_category = Arrays.asList("Single","Double","Suite");
private List<Double> Room_price = Arrays.asList(30.0 , 80.0 , 150.0);
private List<String> Room_type = Arrays.asList("A.C","Non- A.C");
private List<Integer> Room_available = Arrays.asList(100,200,150);
private List<Integer> Food_price = Arrays.asList(30,40,60);
private ArrayList<String> Customer_Name_Adults = new ArrayList<>();
private ArrayList<Integer> Customer_Age_Adult = new ArrayList<>();
private static ArrayList<String> Customer_Phone_No_Adult = new ArrayList<>();
private ArrayList<String> Customer_Gmail = new ArrayList<>();
private ArrayList<String> Customer_Addhar_No_Adult = new ArrayList<>();
private ArrayList<String> Customer_Name_Children = new ArrayList<>();
private ArrayList<Integer> Customer_Age_Children = new ArrayList<>();
private ArrayList<String> Customer_AadharNo_Children = new ArrayList<>();
/* This below function is storing the information of Adults. */
private void customer_info_Adult(String Adult_name, int Adult_age,String Adult_Phone,String Gmail,String Aadhaar_id_Adult){
this.Customer_Name_Adults.add(Adult_name);
this.Customer_Age_Adult.add(Adult_age);
this.Customer_Phone_No_Adult.add(Adult_Phone);
this.Customer_Gmail.add(Gmail);
this.Customer_Addhar_No_Adult.add(Aadhaar_id_Adult);
}
/* This below information is storing the information of children. */
private void customer_info_Children(String Name_Child,int Age_child, String Adhar_Child){
this.Customer_Name_Children.add(Name_Child);
this.Customer_Age_Children.add(Age_child);
this.Customer_AadharNo_Children.add(Adhar_Child);
}
/* This below functions is used to avail food for Single type bed customers. */
private void food_single(String type){
int room_number_single;
System.out.println("\nDear Customer, Do you want to to avail food also." );
System.out.println("Please tell yes or no.");
choice = sc.next();
System.out.println();
if(checkCondition(choice)){
if(type.equals("AC")){
System.out.println("The price of food is $30.0");
updated_price = newprice_ac+ (30*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_single = ra.nextInt(100,200);
}while(!uniqueRoomNumbers.add(room_number_single));
System.out.print(room_number_single);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numbers at $" +updated_price+" with AC and Food.");
}
else if(type.equals("Non AC")){
System.out.println("The price of food is $30.0");
updated_price = newprice_non_ac+ (30*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_single = ra.nextInt(100,200);
}while(!uniqueRoomNumbers.add(room_number_single));
System.out.print(room_number_single);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numnbers at $" +updated_price+ " with Food but not AC.");
}
}
else if(checkCondition(choice)){
if(type.equals("AC")){
updated_price = newprice_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_single = ra.nextInt(100,200);
}while(!uniqueRoomNumbers.add(room_number_single));
System.out.print(room_number_single);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price+ " with AC but not Food.");
}
else if(type.equals("Non AC")){
updated_price = newprice_non_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_single = ra.nextInt(100,200);
}while(!uniqueRoomNumbers.add(room_number_single));
System.out.print(room_number_single);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price+" with no Food and AC." );
}
}
System.out.println();
display_Customer_Info();
System.out.println();
}
/*This below function is used as hcoice type for AC or Non AC in single type bed. */
private void ac_or_non_ac_single(){
System.out.println("Enter what type of room is your preferene");
System.out.println("1. Please Enter 1 for AC.");
System.out.println("2. Please Enter 2 for Non AC.");
int i=0;
int choice1 = sc.nextInt();
System.out.println();
if(choice1 ==1){
System.out.println("You have chosen AC Room.");
newprice_ac = (Room_price.get(i)+ 30)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Single Type AC rooms at $"+newprice_ac+" from "+ check_in+" to "+check_out+" for "+days +" days.");
System.out.println();
food_single("AC");
}
else if(choice1==2){
System.out.println("You have chosen Non AC Room");
newprice_non_ac = Room_price.get(i)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Single Type Non AC rooms at $"+newprice_non_ac+" from "+ check_in+" to "+check_out+" for "+days +" days.");
System.out.println();
food_single("Non AC");
}
}
/*This below function is used for customers who has choosen Singe type bed.*/
private void single_room(){
int i=0;
System.out.println("Please Enter the number of rooms you want");
room = sc.nextInt();
while(room==0){
System.out.println("Number of rooms should not be 0.");
System.out.println("Please Enter the number of rooms you want");
room = sc.nextInt();
}
rooms.add(room);
System.out.println("Please enter the check in date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_in = sc.next();
while(check_in.length()==0 || !check_in.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_in = sc.next();
}
System.out.println();
System.out.println("Please enter the check out date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_out = sc.next();
while(check_in.length()==0|| !check_out.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_out = sc.next();
}
date();
System.out.println();
total_room_remain = Room_available.get(i)-room;
Room_available.set(i, total_room_remain);
if(total_room_remain >= room){
System.out.println("Dear Customer you have booked for: "+room+" Single Type rooms."+" from "+ check_in+" to "+check_out +" for "+days +" days.");
System.out.println();
totalNoOfPersons();
System.out.println();
ac_or_non_ac_single();
}
else{
System.out.println("Sorry we do not have enough rooms");
}
}
//* This below function is used to avail food for Double type bed customers. */
private void food_double(String type1){
int room_number_double;
System.out.println("Dear Customer, Do you want to to avail food also." );
System.out.println("Please tell yes or no.");
choice = sc.next();
System.out.println();
if(checkCondition(choice)){
if(type1.equals("AC")){
System.out.println("The price of food is $40.0");
updated_price = newprice_ac+ (40*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_double = ra.nextInt(201,400);
}while(!uniqueRoomNumbers.add(room_number_double));
System.out.print(room_number_double);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numbers at $" +updated_price+" with Food and AC.");
}
else if(type1.equals("Non AC")){
System.out.println("The price of food is $40.0");
updated_price = newprice_non_ac+ (40*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_double = ra.nextInt(201,400);
}while(!uniqueRoomNumbers.add(room_number_double));
System.out.print(room_number_double);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numbers at $" +updated_price +" with Food but not AC.");
}
}
else if(checkCondition(choice)){
if(type1.equals("AC")){
updated_price = newprice_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_double = ra.nextInt(201,400);
}while(!uniqueRoomNumbers.add(room_number_double));
System.out.print(room_number_double);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price+" with AC but no Food.");
}
else if(type1.equals("Non AC")){
updated_price = newprice_non_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_double = ra.nextInt(201,400);
}while(!uniqueRoomNumbers.add(room_number_double));
System.out.print(room_number_double);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price+ " with Non AC and No Food.");
}
}
System.out.println();
display_Customer_Info();
System.out.println();
}
/*This below function is used as choice type for AC or Non AC in double type bed. */
private void ac_or_non_ac_double(){
System.out.println("Enter what type of room is your preferene");
System.out.println("1. Please Enter 1 for AC");
System.out.println("2. Please Enter 2 for Non AC");
int i=1;
int choice1 = sc.nextInt();
if(choice1 ==1){
System.out.println("You have chosen AC Room");
newprice_ac = (Room_price.get(i)+ 45)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Double Type rooms with AC at $"+newprice_ac+" from "+ check_in+" to "+check_out+" for "+days +" days.");
System.out.println();
food_double("AC");
}
else if(choice1==2){
System.out.println("You have chosen Non AC Room");
newprice_non_ac = Room_price.get(i)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Double Type rooms with Non AC at $"+newprice_non_ac+" from "+ check_in+" to "+check_out+" for "+days +" days.");
System.out.println();
food_double("Non AC");
}
}
/*This below function is used for customers who has choosen Double type bed.*/
private void double_room(){
int i=1;
System.out.println("Dear Customer, Enter the number of rooms you want");
room = sc.nextInt();
while(room==0){
System.out.println("Number of rooms should not be 0.");
System.out.println("Please Enter the number of rooms you want");
room = sc.nextInt();
}
rooms.add(room);
System.out.println("Please enter the check in date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_in = sc.next();
while(check_in.length()==0 || !check_in.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_in = sc.next();
}
System.out.println();
System.out.println("Please enter the check out date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_out = sc.next();
while(check_in.length()==0|| !check_out.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_out = sc.next();
}
date();
System.out.println();
total_room_remain = Room_available.get(i)-room;
Room_available.set(i, total_room_remain);
if(total_room_remain >= room){
System.out.println("Dear Customer you have booked for: "+room+" Double Type room from "+ check_in+" to "+check_out+" for "+days +" days.");
System.out.println();
totalNoOfPersons();
System.out.println();
ac_or_non_ac_double();
}
else{
System.out.println("Sorry we do not have enough rooms");
}
}
/*This below function is used to remove the list or simply remove data when to cancel the ticket. */
private void remove_list(String phone){
if(Customer_Phone_No_Adult.contains(phone)){
int index = phone.indexOf(phone);
Customer_Phone_No_Adult.remove(index);
Customer_Addhar_No_Adult.remove(index);
Customer_Name_Adults.remove(index);
Customer_Age_Adult.remove(index);
Customer_Gmail.remove(index);
if(!Customer_Name_Children.isEmpty()){
Customer_Name_Children.remove(index);
Customer_Age_Children.remove(index);
Customer_AadharNo_Children.remove(index);
}
}
else{
System.out.println("Sorry we do not have any customer with this phone number");
System.exit(0);
}
}
/*This below function is used to cancel the ticket of customers.*/
private void cancel_ticket(){
System.out.println("Do you want to cancel the ticket.");
System.out.println(" Please enter yes or no.");
choice= sc.next();
if(checkCondition(choice)){
System.out.println("Please enter your Phone Number");
String phone = sc.next();
System.out.println("Dear Customer, your ticket has been cancelled.");
System.out.println("Thank you for choosing us.");
remove_list(phone);
System.exit(0);
}
}
/* This below functions is used to avail food for Suite type bed customers. */
private void food_suite(String type2){
int room_number_suite;
System.out.println("Dear Customer, Do you want to to avail food also." );
System.out.println("Please tell yes or no.");
choice = sc.next();
System.out.println();
if(checkCondition(choice)){
if(type2.equals("AC")){
System.out.println("The price of food is $60.0 per day");
updated_price = newprice_ac+ (60*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_suite = ra.nextInt(401,550);
}while(!uniqueRoomNumbers.add(room_number_suite));
System.out.print(room_number_suite);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numbers at $" +updated_price+" with Food and AC");
}
else if(type2.equals("Non AC")){
System.out.println("The price of food is $60.0");
updated_price = newprice_non_ac+ (60*room*days);
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_suite = ra.nextInt(401,550);
}while(!uniqueRoomNumbers.add(room_number_suite));
System.out.print(room_number_suite);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room numbers at $" +updated_price+ " with Food but not AC");
}
}
else if(checkCondition(choice)){
if(type2.equals("AC")){
updated_price = newprice_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_suite = ra.nextInt(401,550);
}while(!uniqueRoomNumbers.add(room_number_suite));
System.out.print(room_number_suite);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price + " with AC but No Food.");
}
else if(type2.equals("Non AC")){
updated_price = newprice_non_ac;
System.out.print("Dear Customer, you have been allocated: ");
while(room!=0){
do{
room_number_suite = ra.nextInt(401,550);
}while(!uniqueRoomNumbers.add(room_number_suite));
System.out.print(room_number_suite);
if(room>1)
System.out.print(",");
room--;
}
System.out.println(" room nummbers at $" +updated_price+" with No Food and AC.");
}
}
System.out.println();
display_Customer_Info();
System.out.println();
}
/*This below function is used to choice type for AC or Non AC in Suite type bed. */
private void ac_or_non_ac_suite(){
System.out.println("Enter what type of room is your preferene");
System.out.println("1. Please Enter 1 for AC");
System.out.println("2. Please Enter 2 for Non AC");
int i=2;
int choice1 = sc.nextInt();
System.out.println();
if(choice1 ==1){
System.out.println("You have chosen AC Room");
newprice_ac = (Room_price.get(i)+ 65)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Suite Type rooms with AC at $"+newprice_ac+" from "+ check_in+" to "+check_out +" for "+days +" days.");
System.out.println();
food_suite("AC");
}
else if(choice1==2){
System.out.println("You have chosen Non AC Room");
newprice_non_ac = Room_price.get(i)*room*days;
System.out.println("Dear Customer you have booked for: "+room+" Suite Type rooms with Non AC at $"+newprice_non_ac+" from "+ check_in+" to "+check_out +" for "+days +" days.");
System.out.println();
food_suite("Non AC");
}
}
/*This below function is used for customers who has choosen Suite type bed.*/
private void suite_room(){
int i=2;
System.out.println("Dear Customer, Enter the number of rooms you want");
room = sc.nextInt();
while(room==0){
System.out.println("Number of rooms should not be 0.");
System.out.println("Please Enter the number of rooms you want");
room = sc.nextInt();
}
rooms.add(room);
System.out.println();
System.out.println("\nPlease enter the check in date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_in = sc.next();
while(check_in.length()==0 || !check_in.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_in = sc.next();
}
System.out.println("\nPlease enter the check out date of yours. ");
System.out.println("Write in DD-MM-YYYY format. ");
check_out = sc.next();
while(check_in.length()==0|| !check_out.matches("^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9]{2}$")){
System.out.println("The format should be DD-MM-YYYY. ");
check_out = sc.next();
}
date();
System.out.println();
total_room_remain = Room_available.get(i)-room;
Room_available.set(i, total_room_remain);
if(total_room_remain >= room){
System.out.println("Dear Customer you have booked for: "+room+" Suite Type rooms from "+check_in+" to "+check_out +" for "+days +" days.");
System.out.println();
totalNoOfPersons();
System.out.println();
ac_or_non_ac_suite();
}
else{
System.out.println("Sorry we do not have enough rooms");
}
}
/* This below function is used to provide the number of days from the check in date to checkout date*/
private void date(){
String[] checkInParts = check_in.split("-");
int day = Integer.parseInt(checkInParts[0]);
int month = Integer.parseInt(checkInParts[1]);
int year = Integer.parseInt(checkInParts[2]);
LocalDate checkInDate = LocalDate.of(year, month, day);
String[] checkOutParts = check_out.split("-");
int checkoutDay = Integer.parseInt(checkOutParts[0]);
int checkoutMonth = Integer.parseInt(checkOutParts[1]);
int checkoutYear = Integer.parseInt(checkOutParts[2]);
LocalDate checkOutDate = LocalDate.of(checkoutYear, checkoutMonth, checkoutDay);
Period period = Period.between(checkInDate, checkOutDate);
days = period.getDays();
}
/* This below function is used for asking for preference which type of room does the user want to book.*/
public void roomToBeBooked(){
while(true){
System.out.println("\nYou are eligible to book rooms. ");
System.out.println("Do you want to book it. Please tell yes or no. ");
choice = sc.next();
System.out.println();
if(checkCondition(choice)){
System.out.println("Dear Customer please tell which type of room is your preference.");
System.out.println();
System.out.println("1. Enter 1 for Single Type.");
System.out.println("2. Enter 2 for Double Type");
System.out.println("3. Enter 3 for Suite Type.");
int choice1 = sc.nextInt();
System.out.println();
switch (choice1) {
case 1:
single_room();
break;
case 2:
double_room();
break;
case 3:
suite_room();
break;
default:
System.out.println("\nWrong Choice");
break;
}
}
else{
System.out.println("\nThank you for your time.");
System.out.println("Thank you for visiting for Hotel Rooms booking System.");
System.exit(0);
}
}
}
/*This below function is used to add the total no persons. */
public void totalNoOfPersons(){
System.out.println("\nEnter the number of Adults.");
System.out.println("Number of Adults should not be 0.");
int adults = sc.nextInt();
while(adults==0){
System.out.println("\nNumber of Adults should not be 0.");
adults = sc.nextInt();
}
System.out.println("\nEnter the number of Children.");
int children = sc.nextInt();
people_database(adults,children);
}
/*THis below function is used to add the names and other details of the customer*/
private void people_database(int Adults,int Children){
while(Adults!=0 || Children!=0){
System.out.println("\nEnter the name of the Adult.");
sc.nextLine();
String adult_name = sc.nextLine();
while(adult_name.isBlank()){
System.out.println("\nPlease enter a valid name");
adult_name = sc.nextLine();
}
System.out.println("\nEnter the Age of an Adult");
int adult_age = sc.nextInt();
sc.nextLine();
while(adult_age<=0){
if (adult_age==0) {
System.out.println("\nAge should be a positive number.");
adult_age = sc.nextInt();
sc.nextLine();
break;
}
System.out.println("\nAge should be greater than 0");
adult_age = sc.nextInt();
sc.nextLine();
}
System.out.println();
System.out.println("Enter the Phone Number.");
System.out.println("The phone number should consists of 10 digits");
String adult_phone = sc.next();
while(adult_phone.length()!=10){
System.out.println("Please enter a valid phone number");
adult_phone = sc.next();
}
System.out.println();
System.out.println("Please Enter the Email. Spaces between are not allowed. Ex pal 123@gmail.com");
System.out.println(" Use anything except for giving spaces in between.");
System.out.println("Email should end with @gmail.com. and length should be between 10 to 35 characters.");
String adult_email = sc.next();
while(!adult_email.endsWith("@gmail.com") ){
System.out.println("Email should end with @gmail.com.");
adult_email = sc.nextLine();
}
while (adult_email.length()>35) {
System.out.println("Email should be between 10 to 35 characters.");
adult_email = sc.nextLine();
}
System.out.println();
System.out.println("Dear Customer, Please give your Aadhaar ID for verification.");
System.out.println("The Aadhar Id should be of 12 Characters Long.");
String Aadhaar_id_Adult = sc.nextLine();
while(Aadhaar_id_Adult.length()!=12){
System.out.println("Please enter a valid Aadhaar ID");
Aadhaar_id_Adult = sc.nextLine();
}
String child_name;
int child_age;
String Aadhaar_id_Children;
System.out.println();
if(Children>0){
System.out.println("Enter the name of the Child.");
child_name = sc.nextLine();
while (child_name.length()==0) {
System.out.println("Enter the name of the Child.");
child_name = sc.nextLine();
}
System.out.println();
System.out.println("Enter the Age of the Child.");
child_age = sc.nextInt();
while(child_age<=0){
if (child_age==0) {
System.out.println("Age should be a positive number.");
child_age = sc.nextInt();
break;
}
System.out.println("Age should be greater than 0");
child_age = sc.nextInt();
sc.nextLine();
}
System.out.println();
System.out.println("Dear Customer, Please give your Childrens Aadhaar ID for verification.");
System.out.println("The Aadhar Id should be of 12 Characters Long.");
Aadhaar_id_Children = sc.nextLine();
while(Aadhaar_id_Children.length()!=12){
System.out.println("Please enter a valid Aadhaar ID");
Aadhaar_id_Children = sc.nextLine();
}
customer_info_Children(child_name, child_age, Aadhaar_id_Children);
Children--;
System.out.println();
}
customer_info_Adult(adult_name, adult_age, adult_phone, adult_email, Aadhaar_id_Adult);
Adults--;
}
System.out.println("Please fill in the remaining details");
System.out.println();
}
/* This below function is used to display the customer information for both children and adults.*/
public void display_Customer_Info(){
int i=0;
System.out.println("Your Booking details are as follows:");
int total_rooms =0;
for(int new_rooms:rooms){
total_rooms+=new_rooms;
}
int new_room = total_rooms;
// Only when for Adults
if(Customer_Name_Children.isEmpty() && Customer_Age_Children.isEmpty() && Customer_Age_Children.isEmpty()){
System.out.printf("\n%-16s | %-5s | %-10s |%-25s | %-12s | %-11s| %-9s | %-9s | %-12s \n ","Name","Age","Phone No","Gmail"," Adhar Id","Rooms Book","Check In","Check Out","Price in $");
System.out.println();
for( i =0;i<Customer_Name_Adults.size();i++){
System.out.printf("\n%-16s | %-5d | %-8s |%-25s | %-12s | %-11d| %-9s | %-8s| %-5.2f \n",Customer_Name_Adults.get(i),Customer_Age_Adult.get(i),Customer_Phone_No_Adult.get(i),Customer_Gmail.get(i),Customer_Addhar_No_Adult.get(i),new_room,check_in,check_out,updated_price);
}
}
else{
// For adults
System.out.printf("\n\n%-18s | %-5s | %-11s |%-25s | %-12s | %-11s| %-9s | %-9s | %-5s \n"," Name"," Age"," Phone","Gmail"," Adhar Id","Rooms Book","Check In","Check out","Price in $");
System.out.println();
for(i =0;i<Customer_Name_Adults.size();i++){
System.out.printf("\n%-18s | %-5d | %-11s |%-25s | %-12s | %-11d| %-9s | %-9s | %-5.2f \n",Customer_Name_Adults.get(i),Customer_Age_Adult.get(i),Customer_Phone_No_Adult.get(i),Customer_Gmail.get(i),Customer_Addhar_No_Adult.get(i),new_room,check_in,check_out,updated_price);
}
System.out.println();
// For children
System.out.printf("\n%-18s | %-17s | %-9s | %-13s ","Guardians Name","Child Name","ChildAge","Child AdharId");
System.out.println();
for(i =0;i<Customer_Name_Children.size();i++){
System.out.printf("\n%-18s | %-18s| %-9d | %-13s \n",Customer_Name_Adults.get(i),Customer_Name_Children.get(i),Customer_Age_Children.get(i),Customer_AadharNo_Children.get(i));
}
}
System.out.println();
cancel_ticket();
}
/* This below function is used to diplay the number of rooms in hotel shanti.*/
public void display_hotel_Shanti(){
System.out.println("The data for the Hotel Shanti are stored as");
System.out.printf("%-17s | %-20s | %-10s | %-10s","Rooms Category","Rooms Original Price","Rooms Available","Food Price");
System.out.println();
for(int i=0;i<Room_category.size()|| i<Room_type.size();i++){
System.out.printf("%-17s | %-20s | %-15s |%-10s ",Room_category.get(i),Room_price.get(i),Room_available.get(i),Food_price.get(i));
System.out.println();