-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment2.java
1453 lines (1323 loc) · 57 KB
/
Assignment2.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
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
import java.util.*;
interface Animal1{
void addAnimal();
void updateAnimal();
void removeAnimal();
}
interface Attraction1{
void addAttraction();
void modify();
void remove();
}
class AttractionAnimal {
private String animal;
private String type;
private String sound;
private String details;
public AttractionAnimal(String animal, String type, String sound, String details) {
this.animal = animal;
this.type = type;
this.sound = sound;
this.details = details;
}
public String getAnimal() {
return animal;
}
public void setAnimal(String animal) {
this.animal = animal;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSound() {
return sound;
}
public void setSound(String sound) {
this.sound = sound;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
}
class Animals_opp extends Admins implements Animal1 {
private String valid;
private Scanner sc = new Scanner(System.in);
private String isValidCategory(String category) {
if (category.equalsIgnoreCase("Mammals") || category.equalsIgnoreCase("Amphibians")
|| category.equalsIgnoreCase("Reptiles")) {
return category;
} else {
return "Not";
}
}
private static int c_mammals = 0;
private static int c_amphibians = 0;
private static int c_reptiles = 0;
public void beforeAddAnimal() {
if(c_mammals < 2 || c_amphibians < 2 || c_reptiles < 2) {
while (c_mammals < 2 || c_amphibians < 2 || c_reptiles < 2) {
addAnimal();
}
}
else if(c_mammals >=2 || c_amphibians >= 2 || c_reptiles >= 2){
addAnimal();
}
}
public void addAnimal() {
System.out.println("Enter the name of animal!");
String name = sc.nextLine();
System.out.println("Enter The category");
String category = sc.nextLine();
String valid = isValidCategory(category);
if (valid.equalsIgnoreCase("Not")) {
System.out.println("Invalid category. Please choose from Mammals, Amphibians, or Reptiles.");
return;
}
System.out.println("Enter the sound of animal:");
String sound = sc.nextLine();
System.out.println("Enter the details of animal:");
String details = sc.nextLine();
if (category.equalsIgnoreCase("Mammals")) {
c_mammals++;
} else if (category.equalsIgnoreCase("Amphibians")) {
c_amphibians++;
} else if (category.equalsIgnoreCase("Reptiles")) {
c_reptiles++;
}
AttractionAnimal newAnimal = new AttractionAnimal(name, category, sound, details);
my_animal.add(newAnimal);
}
public void updateAnimal() {
if (my_animal.isEmpty()) {
System.out.println("No animals available.");
return;
}
System.out.println("Enter the name of the animal you want to update:");
String name = sc.nextLine();
boolean found = false;
for (AttractionAnimal animal : my_animal) {
if (animal.getAnimal().equalsIgnoreCase(name)) {
found = true;
System.out.println("Enter the new details of the animal:");
String newDetails = sc.nextLine();
animal.setDetails(newDetails);
System.out.println("Animal details updated successfully.");
break;
}
}
if (!found) {
System.out.println("Animal not found with the given name");
}
}
public void removeAnimal() {
if (my_animal.isEmpty()) {
System.out.println("No animals available.");
return;
}
System.out.println("Enter the name of the animal you want to remove.");
String name = sc.nextLine();
boolean found = false;
for (Iterator<AttractionAnimal> iterator = my_animal.iterator(); iterator.hasNext();) {
AttractionAnimal animal = iterator.next();
if (animal.getAnimal().equalsIgnoreCase(name)) {
String category = animal.getType();
if(category.equalsIgnoreCase("Mammals") && c_mammals<=2){
System.out.println("Cannot remove. There must be at least 2 Mammals.");
return;
}
else if(category.equalsIgnoreCase("Amphibians") && c_amphibians<=2){
System.out.println("Cannot remove. There must be at least 2 Amphibians.");
return;
}
else if(category.equalsIgnoreCase("Reptiles") && c_reptiles<=2){
System.out.println("Cannot remove. There must be at least 2 Reptiles.");
return;
}
iterator.remove();
found = true;
System.out.println("Animal removed successfully.");
break;
}
}
if (!found) {
System.out.println("Animal not found with the given name");
}
}
public static void viewAnimals() {
if (my_animal.isEmpty()) {
System.out.println("No animals available.");
} else {
System.out.println("List of Animals:");
for (AttractionAnimal animal : my_animal) {
System.out.println("Animal Name : " + animal.getAnimal() + " Category: " + animal.getType());
}
}
}
public static void visitAnimals() {
System.out.println("Enter the name of animals which you want to visit");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
int flag = 0;
for (AttractionAnimal a : my_animal) {
if (a.getAnimal().equals(name)) {
flag = 1;
System.out.println("Enter whether you want to feed or read\n" +
"1.feed" +
"2.read");
int b = sc.nextInt();
if (b == 1) {
System.out.println("Animal sound: " + a.getSound());
} else if (b == 2) {
System.out.println("Animal Description: " + a.getDetails());
} else {
System.out.println("Wrong Option!!!!");
}
break;
}
}
if (flag == 0) {
System.out.println("There is no such Animal!");
}
}
}
class Discount {
private static double student = 0;
public static double minor = 10;
private static double senior = 20;
private static boolean st1 = false;
private static boolean st2 = false;
private static double st_1 = 15;// for special deals when more than 2 tickets buy
private static double st_2 = 30;// for special deals when more than 3 tickets buy
public static double getStudent() {
return student;
}
public static void setStudent(double stu) {
student = stu;
}
public static double getMinor() {
return minor;
}
public static void setMinor(double min) {
minor = min;
}
public static double getSenior() {
return senior;
}
public static void setSenior(double sen) {
senior = sen;
}
public static double getSt_1() {
return st_1;
}
public static void setSt_1(double st_1) {
Discount.st_1 = st_1;
}
public static double getSt_2() {
return st_2;
}
public static void setSt_2(double st_2) {
Discount.st_2 = st_2;
}
public static boolean isSt1() {
return st1;
}
public static void setSt1(boolean st1) {
Discount.st1 = st1;
}
public static boolean isSt2() {
return st2;
}
public static void setSt2(boolean st2) {
Discount.st2 = st2;
}
}
class Discount_opp extends Admins {
public void addDiscount() {
System.out.println(
"Enter the name, you want to set discount for the following:\n1.Student\n2.minor\n3.Senior\n4.Attraction");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
System.out.println("Enter the discount percentage you want to set:");
double b = sc.nextDouble();
sc.nextLine();
if (a == 1) {
Discount.setStudent(b);
} else if (a == 2) {
Discount.setMinor(b);
} else if (a == 3) {
Discount.setSenior(b);
} else if (a == 4) {
System.out.println("Enter the name of attraction:");
String name = sc.nextLine();
int flag = 0;
for (Attraction att : my_attraction) {
if (att.getName().equals(name) && att.isSchedule()) {
flag = 1;
att.setDiscount(b);
System.out.println("Discount added successfully!");
break;
}
}
if (flag == 0) {
System.out.println("This name of attraction is neither exist nor scheduled");
}
}
}
public void modifyDiscount() {
System.out.println(
"Enter the name you want to change discount for the following:\n1.Student\n2.minor\n3.Senior\n4.Attraction");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
System.out.println("Enter the discount percentage you want to change:");
double b = sc.nextDouble();
if (a == 1) {
Discount.setStudent(b);
System.out.println("Discount Modified successfully!");
} else if (a == 2) {
Discount.setMinor(b);
System.out.println("Discount Modified successfully!");
} else if (a == 3) {
Discount.setSenior(b);
System.out.println("Discount Modified successfully!");
} else if (a == 4) {
System.out.println("Enter the name of attraction:");
String name = sc.nextLine();
for (Attraction att : my_attraction) {
if (att.getName().equals(name)) {
att.setDiscount(b);
System.out.println("Discount added successfully to attraction!");
break;
}
}
}
}
public void removeDiscount() {
System.out.println("Enter the of category of which you want to set discount zero:");
System.out.println("1.Student");
System.out.println("2.Minor");
System.out.println("3.Senior");
System.out.println("4.Attraction");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a == 1) {
Discount.setStudent(0);
System.out.println("Discounts for Students set to zero.");
return;
} else if (a == 2) {
Discount.setMinor(0);
System.out.println("Discounts for Minors set to zero.");
return;
} else if (a == 3) {
Discount.setSenior(0);
System.out.println("Discount for Seniors set to zero.");
return;
} else if (a == 4) {
System.out.println("Enter the name of attraction:");
String name = sc.nextLine();
boolean found = false;
for (Attraction att : my_attraction) {
if (name.equals(att.getName())) {
att.setDiscount(0);
found = true;
System.out.println("Discount for Attraction set to zero.");
break;
}
}
if(!found){
System.out.println("Attraction not found with the given name.");
}
}else{
System.out.println("Invalid choice. Please choose a valid option.");
}
}
public void printDiscount() {
System.out.println("The discount given to the different category is as follows:");
System.out.println("Student: " + Discount.getStudent());
System.out.println("Minor: " + Discount.getMinor());
System.out.println("Senior: " + Discount.getSenior());
// System.out.println("Attraction: " + Discount.getStudent());
}
public void setSpecialDeals() {
Discount.setSt1(true);
Discount.setSt2(true);
System.out.println(
"Special deals are set according to their values which is given in the question\n Buy two tickets get 15% additional discount\n Buy more than 3 tickets get 30% additional discounts");
}
}
class Admins {
private static final String userName = "name";
private static final String passWord = "1234";
public static double revenue = 0;
public static boolean verifiedCredential(String name, String pw) {
return (name.equals(userName) && pw.equals(passWord));
}
public static List<Visitor> my_visitor = new ArrayList<>();
public static List<Attraction> my_attraction = new ArrayList<>();
public static List<Discount> my_discount = new ArrayList<>();
public static List<AttractionAnimal> my_animal = new ArrayList<>();
int flag = 0;
public int count_v = 0;
public void count_no_of_visitor(){
for(Visitor v: my_visitor){
count_v++;
}
}
// public int max = 0;
public void viewVisitorStats() {
count_no_of_visitor();
System.out.println("Number of visitors are: " + count_v + " Total revenue: " + revenue);
System.out.println("Visitors list are:");
for (Visitor v : my_visitor) {
flag = 1;
System.out.println("Name: " + v.getName() + " Age: " + v.getAge() + " Phone Number: " + v.getPhoneNumber()
+ " Balance: " + v.getBalance() + " Email: " + v.getEmail());
}
if (flag == 0) {
System.out.println("No registered members!");
}
}
}
class Attraction {
private static int att_count = 1;
private String name;
private String description;
private boolean schedule;
private String id;
private double price;
private double discount = 0;
private double ticket = 0;
public Attraction(String name, String Description, boolean sch, double discount, double price, int ticket) {
this.name = name;
this.description = Description;
this.schedule = sch;
this.discount = discount;
this.price = price;
this.ticket = ticket;
this.id = "A" + att_count;
att_count++;
}
public double getTicket() {
return ticket;
}
public void setTicket(double ticket) {
this.ticket = ticket;
}
public static int getAtt_count() {
return att_count;
}
public static void setAtt_count(int att_count) {
Attraction.att_count = att_count;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isSchedule() {
return schedule;
}
public void setSchedule(boolean schedule) {
this.schedule = schedule;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
class Attraction_opp extends Admins implements Attraction1 {
// public static List<AttractionM> my_attraction = new ArrayList<>();
private boolean schedule;
public void addAttraction() {
double at_pr = 0;
Scanner an = new Scanner(System.in);
System.out.println("Enter Attraction Name:");
String at_name = an.nextLine();
System.out.println("Enter Attraction Description:");
String at_des = an.nextLine();
System.out.println("Enter the ticket price for the attraction:");
at_pr = an.nextDouble();
an.nextLine();
Attraction att = new Attraction(at_name, at_des, false, 0, at_pr, 0);
my_attraction.add(att);
System.out.println("Attraction Added Successfully!");
}
public static void viewEvents() {
System.out.println("Attractions in the Zoo:");
for (Attraction attraction : my_attraction) {
// System.out.println("ID: "+ attraction.getId());
System.out.println("Attraction Name: " + attraction.getName() + " Attraction Id: " + attraction.getId());
// System.out.println("Description: "+ attraction.getDescription());
}
}
public void modify() {
viewEvents();
System.out
.println("If You Want To Edit Id, Name and Description Then Enter The Id Of Which You Want To Change:");
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
for (Attraction attraction : my_attraction) {
if (attraction.getId().equals(input)) {
System.out.println("Do You Want To Change The Name With The Old Name:\nEnter 'Yes' or 'No'");
String change_name = sc.nextLine();
if (change_name.equalsIgnoreCase("Yes")) {
System.out.println("Current Name: " + attraction.getName());
System.out.println("Enter the new Name:");
String new_name = sc.nextLine();
attraction.setName(new_name);
} else if (change_name.equalsIgnoreCase("No")) {
System.out.println("Okay!");
}
System.out.println("Do You Want To Change The Description\nEnter 'yes' or 'No'");
String change_description = sc.nextLine();
if (change_description.equalsIgnoreCase("Yes")) {
System.out.println("Enter the new description");
String new_description = sc.nextLine();
attraction.setDescription(new_description);
} else if (change_description.equalsIgnoreCase("No")) {
System.out.println("Okay!");
}
}
System.out.println("Attraction details updated successfully!");
return;
}
}
public void remove() {
System.out.println("Enter The Id Of The Attraction Which You Want To Remove:");
Scanner sc = new Scanner(System.in);
String id = sc.nextLine();
for (Attraction attraction : my_attraction) {
if (attraction.getId().equals(id)) {
my_attraction.remove(attraction);
System.out.println("Attraction with Id " + id + "removed successfully!");
return;
}
}
System.out.println("Attraction with Id " + id + " not found");
}
public void scheduleEvents() {
System.out.println("Enter The Name Of The Attraction Which You Want To Schedule:");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
int flag = 0;
for (Attraction attraction : my_attraction) {
if (attraction.getName().equals(name)) {
attraction.setSchedule(true);
System.out.println("Attraction is scheduled successfully!");
flag = 1;
break;
}
}
if (flag == 0) {
System.out.println("The given name is not in The Attraction list!");
}
}
public void printScheduleEvents() {
System.out.println("The Schedule Events are:");
for (Attraction attraction : my_attraction) {
if (attraction.isSchedule() == true) {
System.out.println("Attraction Name:" + attraction.getName() + "Ticket Price: ");
}
}
}
public static void visitAttraction() {
System.out.println("Enter the Attraction name which you want to visit:");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
int flag = 0;
for (Attraction a : my_attraction) {
if (a.getName().equals(name) && a.getTicket() != 0) {
flag = 1;
System.out.println("you can visit Attraction , you have the ticket");
break;
}
}
if (flag == 0) {
System.out.println("ether this attraction name is not present or may be you do not have tickets!");
}
}
}
class Visitor extends Admins {
private String name;
private int age;
private String phoneNumber;
private double balance;
private String email;
private String password;
private int memberShip;
private double ticketPrice;
// private static List<Visitor> my_visitor = new ArrayList<>();
private String feedback;
private HashMap<String, Integer> my_tickted_map;
public void setMy_tickted_map(HashMap<String, Integer> my_tickted_map) {
this.my_tickted_map = my_tickted_map;
}
public HashMap<String, Integer> getMy_tickted_map() {
return my_tickted_map;
}
// public static double revenue = 0;
public Visitor(String name, int age, String phoneNumber, double balance, String email, String password,
int memberShip, double ticketPrice, String feed, HashMap<String, Integer> map) {
this.name = name;
this.age = age;
this.phoneNumber = phoneNumber;
this.balance = balance;
this.email = email;
this.password = password;
this.memberShip = memberShip;
this.ticketPrice = ticketPrice;
this.feedback = feed;
this.my_tickted_map = map;
}
public int getMemberShip() {
return memberShip;
}
public void setMemberShip(int memberShip) {
this.memberShip = memberShip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public double getTicketPrice() {
return ticketPrice;
}
public void setTicketPrice(double ticketPrice) {
this.ticketPrice = ticketPrice;
}
public void setFeedback(String feedback) {
this.feedback = feedback;
}
public String getFeedback() {
return feedback;
}
public static boolean login() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Visitor Email:");
String email = sc.nextLine();
System.out.println("Enter Visitor Password:");
String ps = sc.nextLine();
int flag = 0;
for (Visitor v : Admins.my_visitor) {
if (v.getEmail().equals(email) && v.getPassword().equals(ps)) {
System.out.println("Login successfully!");
v.start_visitor_loop();
flag = 1;
return true;
/*
*/
}
}
if(flag==0){
System.out.println("Login details are wrong!!!!!");
}
return false;
}
public void start_visitor_loop() {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Visitor Menu:");
System.out.println("1.Explore the Zoo");
System.out.println("2.Buy Membership");
System.out.println("3.Buy Tickets");
System.out.println("4.View Discounts");
System.out.println("5.View Special Deals");
System.out.println("6.Visit Animal");
System.out.println("7.Visit Attractions");
System.out.println("8.Leave Feedback");
System.out.println("9.Log Out");
System.out.println("-------------------------------------------------------\n");
int b5 = sc.nextInt();
if (b5 == 1) {
while (true) {
System.out.println("1.View Attractions");
System.out.println("2.View Animals");
System.out.println("3.Exit");
int b6 = sc.nextInt();
if (b6 == 1) {
Attraction_opp.viewEvents();
} else if (b6 == 2) {
Animals_opp.viewAnimals();
} else {
break;
}
}
} else if (b5 == 2) {
System.out.println("1.Basic Membership(Rs 20)");
System.out.println("2.Premium Membership(Rs 50)");
int b6 = sc.nextInt();
if (b6 == 1) {
basicMembership();
// flag = 1;
} else if (b6 == 2) {
premiumMembership();
// flag = 1;
}
} else if (b5 == 3) {
if (flag == 1) {
System.out.println("Buy Tickets:");
buyTickets();
} else {
System.out.println("You have to buy the membership first!");
}
} else if (b5 == 4) {
viewDiscounts();
} else if (b5 == 5) {
System.out.println("Get 2 Tickets and get 15% additional discounts");
System.out.println("Get 3 or more Tickets and get 30% additional discounts");
} else if (b5 == 6) {
if (this.getMemberShip() == 0) {
// has no mem yet
System.out.println("Buy a Membership First!!!");
continue;
}
Animals_opp.visitAnimals();
} else if (b5 == 7) {
//Attraction_opp.visitAttraction();
visitor_visit_attraction();
} else if (b5 == 8) {
giveFeedback();
} else if (b5 == 9) {
break;
} else {
System.out.println("Wrong Option!!!");
}
}
}
public void basicMembership() {
// 1 for basic
if (this.getBalance() >= 20) {
// valid to buy membership
double balance = this.getBalance();
this.setBalance(balance - 20);
System.out.println(" Basic Membership Purchased :)");
this.setMemberShip(1);
flag = 1;
} else {
System.out.println("Balance Not enough!!");
}
}
public void premiumMembership() {
// 2 for premium
if (this.getBalance() >= 50) {
// valid to buy membership
double balance = this.getBalance();
this.setBalance(balance - 50);
System.out.println(" Premium Membership Purchased :)");
this.setMemberShip(2);
flag = 1;
} else {
System.out.println("Balance Not enough!!");
}
}
public void buyTickets() {
Scanner sc = new Scanner(System.in);
int flag = 0;
double price = 0;
System.out.println();
if (this.getMemberShip() == 2) {
System.out.println("You don't need tickets as u are a premium member.....");
return;
}
System.out.println("Enter the number of tickets you want to buy:");
int not = sc.nextInt();
sc.nextLine();
if (not <= 0) {
System.out.println("Wrong Option for Tickets!!");
return;
}
System.out.println("These are the list of Attraction according to their ticket price:");
for (Attraction a : my_attraction) {
if (a.isSchedule() == true) {
System.out.println(
"Name: " + a.getName() + "\nId: " + a.getId() + "\nDescription: " + a.getDescription()
+ "\nPrice of Ticket: " + a.getPrice() + "\nDiscount: " + a.getDiscount() + "%");
}
}
System.out.println("Enter The Name of attraction for which you want to buy ticket :");
String name = sc.nextLine();
double visitor_balance = this.getBalance();
for (Attraction attraction : my_attraction) {
if (attraction.getName().equals(name)) {
flag = 1;
double attraction_price = attraction.getPrice();
if (not == 1) {
// only discount coupans , no deal
System.out.println("Coupon codes, enter according to their number:");
viewDiscounts();
System.out.println("4. None");
int option = sc.nextInt();
sc.nextLine();
if (option == 1) {
// student
if(this.age < 15){
double total_price = not*attraction_price;
double student_discount = ((Discount.getStudent())/100)*total_price;
double net_price = total_price - student_discount;
if(this.getBalance()>=net_price){
this.setBalance(visitor_balance-net_price);
this.my_tickted_map.put(attraction.getName(),not);
revenue = revenue + net_price;
System.out.println("Tickets purchased successfully!");
System.out.println("Your Balance is now: " + this.getBalance());
}
else {
System.out.println("Not Enough Balance!!");
return;
}
}
else{
System.out.println("Can't apply this code!!!!!");
}
} else if (option == 2) {
// minor
if (this.getAge() < 18) {
// valid minor here
double total_price = not * attraction_price;
double minor_discount = ((Discount.getMinor()) / 100) * total_price;
double net_price = total_price - minor_discount;
// now check whether he has money or not or maybe he is gareeb for now
if (this.getBalance() >= net_price) {
// ameer h visitor
this.setBalance(visitor_balance - net_price);
this.my_tickted_map.put(attraction.getName(), not);
revenue = revenue + net_price;
System.out.println("Tickets Purchased successfully");
System.out.println("Your Balance is Now: " + this.getBalance());
} else {
// garreb h visitor
System.out.println("Not Enough Balance!!");
return;
}
} else {
System.out.println("Cant Apply this code!!!!!");
return;
}
} else if (option == 3) {
// senior
if (this.getAge() > 60) {
// valid minor here
double total_price = not * attraction_price;
double senior_discount = ((Discount.getSenior()) / 100) * total_price;
double net_price = total_price - senior_discount;
// now check whether he has money or not or maybe he is gareeb for now
if (this.getBalance() >= net_price) {
// ameer h visitor
this.setBalance(visitor_balance - net_price);
this.my_tickted_map.put(attraction.getName(), not);
revenue = revenue + net_price;
System.out.println("Tickets Purchased successfully");
System.out.println("Your Balance is Now: " + this.getBalance());
} else {
// garreb h visitor
System.out.println("Not Enough Balance!!");
return;
}
} else {
System.out.println("Cant Apply this code!!!!!");
return;
}
} else if (option == 4) {
// none
double total_price = not * attraction_price;
// now check whether he has money or not or maybe he is gareeb for now
if (this.getBalance() >= total_price) {
// ameer h visitor
this.setBalance(visitor_balance - total_price);
this.my_tickted_map.put(attraction.getName(), not);
revenue = revenue + total_price;
System.out.println("Ticktes Purchased successfully");
System.out.println("Your Balance is Now: " + this.getBalance());
} else {
// garreb h visitor
System.out.println("Not Enough Balance!!");
return;
}