-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCampButterfliesDriver.java
1074 lines (1007 loc) · 38.4 KB
/
CampButterfliesDriver.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.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Scanner;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* the UI code for the Camp Butterfly program
*/
public class CampButterfliesDriver {
private Scanner scan;
private String[] homepageOptions = new String[7];
private CampFacade facade = new CampFacade();
/**
* Creates the driver and initializes the scanner
*/
public CampButterfliesDriver(CampFacade facade) {
this.facade = facade;
scan = new Scanner(System.in);
homepageOptions[0] = "View Activities";
homepageOptions[1] = "View Available Weeks";
homepageOptions[2] = "View Pricing and Discounts";
homepageOptions[3] = "Contact the Camp";
homepageOptions[4] = "Create an Account";
homepageOptions[5] = "Login";
homepageOptions[6] = "Quit";
}
/**
* starts running the system
*/
public void run() {
boolean running = true;
while (running) {
homepage();
int choice = scan.nextInt();
scan.nextLine();
clear();
switch (choice) {
case 1:
activites();
break;
case 2:
weeks();
break;
case 3:
price();
break;
case 4:
contact();
break;
case 5:
createAccount();
break;
case 6:
login();
break;
case 7:
System.out.println("Have a good day!");
running = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
pause();
}
}
/**
* Prints out activities for a certain camp
*/
private void activites() {
System.out.println("Which camp's activities would you like to see?");
System.out.println(facade.getCamps());
System.out.println(facade.getActivities(scan.nextLine()));
}
/**
* Prints out the available weeks for a certain camp
*/
private void weeks() {
System.out.println("Which camps sessions would you like to see?");
System.out.println(facade.getCamps());
String camp = scan.nextLine();
int i = 1;
for (Week week : facade.getWeeks(camp)) {
System.out.println("Week " + i + ": " + week);
i++;
}
}
/*
* Clears the console
*/
private void clear() {
System.out.print("\033[H\033[2J");
}
/**
* prints the hompage UI
*/
private void homepage() {
System.out.println("\n\tWelcome to Camp Blue Butterflies");
System.out.println("-----------------------------------------------");
for (int i = 0; i < homepageOptions.length; i++) {
System.out.println((i + 1) + ". " + homepageOptions[i]);
}
}
/**
* Pauses the code to give users time to look at the new information
*/
private void pause() {
try {
TimeUnit.MILLISECONDS.sleep(600);
} catch (Exception e) {
System.out.println("Timer error");
}
}
/**
* Prints out camp price and available discounts
*/
private void price() {
System.out.println("The general price of our camp is $675\n" +
"Discounts Available:\n" +
"\tReturning Camper - 10% off\n" +
"\t2+ Campers Registered - 10% off\n" +
"\tRegsistered for Multiple Weeks - 10% off");
}
/**
* Prints out the campscontact information
*/
private void contact() {
System.out.println("Contact us with any questions or concerns\n" +
"Phone Number: 555-123-CAMP\n" +
"Email: [email protected]");
}
/**
* Lets the user create a new account
*/
private void createAccount() {
System.out.println("Would you like to create a \n1. Parent Account \n2. Counselor Account");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
createUser();
break;
case 2:
createCounselor();
;
break;
}
}
/**
* Creates a new user with campers
*/
private void createUser() {
String username = get("Username");
String password = get("Password");
LoginInfo loginInfo = new LoginInfo(username, password);
String firstName = get("First Name");
String lastName = get("Last Name");
String homeAddress = get("Home Address");
String dateOfBirth = get("Date of Birth(MM/DD/YYYY)");
Date doB = formatDate(dateOfBirth);
ArrayList<Camper> campers = new ArrayList<>();
boolean more = true;
while (more) {
System.out.println("\nCamper Information");
Camper camper = createCamper();
campers.add(camper);
String answer = get("Would you like to add more campers?(yes/no)");
if (answer.equalsIgnoreCase("no"))
more = false;
}
facade.addUser(firstName, lastName, doB, homeAddress, loginInfo, campers);
}
/**
* Creates a new camper
*
* @return camper that was made
*/
private Camper createCamper() {
String firstName = get("First Name");
String lastName = get("Last Name");
String homeAddress = get("Home Address");
String dateOfBirth = get("Date of Birth(MM/DD/YYYY)");
Date doB = formatDate(dateOfBirth);
Sex sex = Enum.valueOf(Sex.class, get("Sex(MALE/FEMALE)"));
String med = get("Would you like to add any medications(yes/no)");
ArrayList<Medication> medications = new ArrayList<>();
if (med.equalsIgnoreCase("yes")) {
boolean more = true;
while (more) {
String type = get("Medication Name");
String dose = get("Dose Amount");
String time = get("Time Taken");
Medication newMeds = new Medication(type, dose, time);
medications.add(newMeds);
String answer = get("Would you like to add more(yes/no)");
if (answer.equalsIgnoreCase("no"))
more = false;
}
}
ArrayList<String> allergies = new ArrayList<>();
boolean moreAllergies = true;
while (moreAllergies) {
String allergy = get("Allergies");
allergies.add(allergy);
String answer = get("Would you like to add more allergies?(yes/no)");
if (answer.equalsIgnoreCase("no"))
moreAllergies = false;
}
System.out.println("\nDoctor Information");
String relationToPerson = "Pediatrician";
String doctorFirstName = get("First Name");
String doctorLastName = get("Last Name");
String phoneNumber = get("Phone Number");
String doctorAddress = get("Email Address");
Contact pediatrician = new Contact(doctorFirstName, doctorLastName, phoneNumber, doctorAddress,
relationToPerson);
System.out.println("\nEmergency Contacts");
ArrayList<Contact> emergencyContacts = new ArrayList<>();
boolean moreContacts = true;
while (moreContacts) {
String contactFirstName = get("First Name");
String contactLastName = get("Last Name");
String conatctphoneNumber = get("Phone Number");
String contactAddress = get("Email Address");
String conatctrelationToPerson = get("Relation To Person");
Contact contact = new Contact(contactFirstName, contactLastName, conatctphoneNumber, contactAddress,
conatctrelationToPerson);
emergencyContacts.add(contact);
String answer = get("Would you like to add more emergency contacts?(yes/no)");
if (answer.equalsIgnoreCase("no"))
moreContacts = false;
}
Camper camper = facade.addCamper(firstName, lastName, homeAddress, doB, sex, medications, allergies,
emergencyContacts,
pediatrician);
System.out.println("\nWhich camp would you like to sign up for?");
System.out.println(facade.getCamps());
String camp = scan.nextLine();
System.out.println("Pick a week");
boolean moreWeeks = true;
while (moreWeeks) {
int i = 1;
for (Week week : facade.getWeeks(camp)) {
System.out.println("Week " + i + ": " + week);
i++;
}
System.out.print("Week Number:");
int week = scan.nextInt();
scan.nextLine();
facade.getCampList().getCamp(camp).getWeek(week); // saves it here?
camper.addWeek(week);
if (!camper.selectWeek(facade.getCampList().getCamp(camp), week)) {
System.out.println("Week is full");
} else {
System.out.println(camper.getFirstName() + " is signed up for week " + week + "!");
}
String answer = get("Would you like to add another week?(yes/no)");
if (answer.equalsIgnoreCase("no"))
moreWeeks = false;
}
return camper;
}
/**
* Creates a new counselor
*/
private void createCounselor() {
String username = get("Username");
String password = get("Password");
LoginInfo loginInfo = new LoginInfo(username, password);
String firstName = get("First Name");
String lastName = get("Last Name");
String phoneNumber = get("Phone Number");
String emailAddress = get("Email Address");
String homeAddress = get("Home Address");
String dateOfBirth = get("Date of Birth(MM/DD/YYYY)");
Date doB = formatDate(dateOfBirth);
System.out.println("\nDoctor Information");
String relationToPerson = "Pediatrician";
String doctorFirstName = get("First Name");
String doctorLastName = get("Last Name");
String doctorphoneNumber = get("Phone Number");
String doctorAddress = get("Email Address");
Contact pediatrician = new Contact(doctorFirstName, doctorLastName, doctorphoneNumber, doctorAddress,
relationToPerson);
System.out.println("\nEmergency Contacts");
ArrayList<Contact> emergencyContacts = new ArrayList<>();
boolean moreContacts = true;
while (moreContacts) {
String contactFirstName = get("First Name");
String contactLastName = get("Last Name");
String conatctphoneNumber = get("Phone Number");
String contactAddress = get("Email Address");
String conatctrelationToPerson = get("Relation To Person");
Contact contact = new Contact(contactFirstName, contactLastName, conatctphoneNumber, contactAddress,
conatctrelationToPerson);
emergencyContacts.add(contact);
String answer = get("Would you like to add more emergency contacts?(yes/no)");
if (answer.equalsIgnoreCase("no"))
moreContacts = false;
}
Counselor counselor = facade.addCounselor(firstName, lastName, phoneNumber, emailAddress, homeAddress, doB,
emergencyContacts,
pediatrician, loginInfo);
System.out.println("Which camp would you like to sign up for?");
System.out.println(facade.getCamps());
String camp = scan.nextLine();
System.out.println("Pick a week");
boolean moreWeeks = true;
while (moreWeeks) {
int i = 1;
for (Week week : facade.getWeeks(camp)) {
System.out.println("Week " + i + ": " + week);
i++;
}
int weeknum = Integer.parseInt(get("Week Number"));
counselor.selectWeek(facade.getCampList().getCamp(camp), weeknum);
String answer = get("Would you like to add another week?(yes/no)");
if (answer.equalsIgnoreCase("no"))
moreWeeks = false;
}
}
/**
* Logs someone in if their credentials match the database
*/
private void login() {
String userName = get("Username");
String password = get("Password");
LoginInfo loginInfo = new LoginInfo(userName, password);
int loginnum = facade.Login(loginInfo);
if (loginnum == 1) {
directorScreen();
} else if (loginnum == 2) {
userScreen();
} else if (loginnum == 3) {
counselorScreen();
} else
System.out.println("Username and Password are not valid");
}
/**
* Formats questions and returns teh users answer
*
* @param prompt
* @return users input
*/
private String get(String prompt) {
System.out.print(prompt + ": ");
return scan.nextLine();
}
/**
* formats a string into a date class
*
* @param date
* @return date
*/
private Date formatDate(String date) {
try {
return new SimpleDateFormat("MM/dd/yyyy").parse(date);
} catch (ParseException e) {
System.out.println("Sorry " + date + " is not a valid date");
return null;
}
}
/**
* Welcomes the user once they sign in with their first and last name
*/
private void welcomeUserScreen() {
System.out.println("\nWelcome Back, " + facade.getCurrentUser().getFirstName() + " "
+ facade.getCurrentUser().getLastName() + "!");
}
/**
* Welcomes the user once they sign in with their first and last name
*/
private void welcomeDirectorScreen() {
System.out.println("\nWelcome Back, " + facade.getCurrentDirector().getFirstName() + " "
+ facade.getCurrentDirector().getLastName() + "!");
}
/**
* Welcomes the user once they sign in with their first and last name
*/
private void welcomeCounselorScreen() {
System.out.println("\nWelcome Back, " + facade.getCurrentCounselor().getFirstName() + " "
+ facade.getCurrentCounselor().getLastName() + "!");
}
/**
* The screen users see when they login
*/
private void userScreen() {
welcomeUserScreen();
boolean run = true;
while (run) {
userOptions();
int option = scan.nextInt();
scan.nextLine();
clear();
switch (option) {
case 1:
System.out.println(facade.viewUserProfile());
break;
case 2:
editUser();
break;
case 3:
String view = chooseCamper("view");
System.out.println(facade.viewCamperProfile(view));
break;
case 4:
String edit = chooseCamper("edit");
editCamper(edit);
break;
case 5:
Camper camper = createCamper();
facade.getCurrentUser().addCamper(camper);
break;
case 6:
discount();
break;
case 7:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
pause();
}
}
/**
* Prints the options the user has
*/
private void userOptions() {
System.out.println("1. View My Profile\n2. Edit My Profile\n3. View My Existing Campers\n" +
"4. Edit My Existing Campers\n5. Register New Camper\n6. View discounts\n7. Logout");
}
/**
* Displays all the campers that the user has and lets them choose one
*/
private String chooseCamper(String action) {
System.out.println("Your Current Campers: \n" + facade.viewCampers());
System.out.println("Please enter the first name of the one you want to " + action + ": ");
return scan.nextLine();
}
/**
* Prints out the users total in the camp
*/
private void discount() {
if (facade.qualifiesForDiscount())
System.out.println("You qualify for a 10% discount!");
else
System.out.println("You do not qualify for a discount");
}
/**
* Gives the user options to edit their profile, then edits the profile
*/
private void editUser() {
boolean run = true;
while (run) {
System.out.println("What would you like to edit:\n1. First Name \n2. Last Name" +
"\n3. Home Address\n4. Date of Birth\n5. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
String newfirstname = get("First Name");
facade.editUserFirstName(newfirstname);
break;
case 2:
String newlastname = get("Last Name");
facade.editUserLastName(newlastname);
break;
case 3:
String newhomeaddress = get("Home Address");
facade.editUserHomeAddress(newhomeaddress);
break;
case 4:
String newdob = get("Date of Birth(MM/DD/YYYY");
facade.editUserDateOfBirth(formatDate(newdob));
break;
case 5:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
}
}
/**
* edits the campers profile
*
* @param firstname name of camper being edited
*/
private void editCamper(String firstname) {
boolean run = true;
while (run) {
System.out.println("What would you like to edit:\n1. First Name \n2. Last Name" +
"\n3. Home Address\n4. Date of Birth\n5. Sex\n6. Allergies" +
"\n7. Emergency Contacts\n8. Doctor Information\n9. Add a Week\n10. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
String newfirstname = get("First Name");
facade.editCamperFirstName(firstname, newfirstname);
break;
case 2:
String newlastname = get("Last Name");
facade.editCamperLastName(firstname, newlastname);
break;
case 3:
String newhomeaddress = get("Home Address");
facade.editCamperHomeAddress(firstname, newhomeaddress);
break;
case 4:
String newdob = get("Date of Birth(MM/DD/YYYY");
facade.editCamperDateOfBirth(firstname, formatDate(newdob));
break;
case 5:
Sex newdate = Enum.valueOf(Sex.class, get("Sex(MALE/FEMALE)"));
facade.editCamperSex(firstname, newdate);
break;
case 6:
editAllergies(firstname);
break;
case 7:
facade.editCamperEmergencyContacts(firstname,
editEC(facade.getCurrentUser().getCamper(firstname).getEmergencyContacts()));
break;
case 8:
facade.editCamperPediatrician(firstname,
editDoctor(facade.getCurrentUser().getCamper(firstname).getPediatrician()));
case 9:
System.out.println(facade.getCamps());
String camp = get("Choose a Camp");
int week = Integer.parseInt(get("Week Number"));
facade.editCamperWeek(firstname, week, camp);
case 10:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
}
}
/**
* edits the campers allergy information
*
* @param camper
*/
private void editAllergies(String camper) {
ArrayList<String> newAllergies = (ArrayList<String>) facade.getCurrentUser().getCamper(camper).getAllergies()
.clone();
boolean run = true;
while (run) {
System.out.println("1. Delete An Existing Allergy\n2.Add A New Allergy\n3. Finish Editing Allergies");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
System.out.println("Choose an allergy to delete");
for (int i = 0; i < newAllergies.size(); i++) {
System.out.println((i + 1) + ". " + newAllergies.get(i));
}
newAllergies.remove(scan.nextInt() - 1);
scan.nextLine();
break;
case 2:
newAllergies.add(get("Allergy"));
break;
case 3:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
}
facade.editCamperAllergies(camper, newAllergies);
}
/**
* edits emergency contacts
*
* @param emergencyContacts
* @return the edited arrayList
*/
private ArrayList<Contact> editEC(ArrayList<Contact> emergencyContacts) {
System.out.println("1. Add New Emergency Contact\n2. Remove An Existing Emergency Contact");
int choice = scan.nextInt();
scan.nextLine();
if (choice == 1) {
System.out.println("New Emergency Contact");
String contactFirstName = get("First Name");
String contactLastName = get("Last Name");
String conatctphoneNumber = get("Phone Number");
String contactAddress = get("Email Address");
String conatctrelationToPerson = get("Relation To Person");
Contact contact = new Contact(contactFirstName, contactLastName, conatctphoneNumber, contactAddress,
conatctrelationToPerson);
emergencyContacts.add(contact);
} else if (choice == 2) {
System.out.println("Remove: ");
for (int i = 0; i < emergencyContacts.size(); i++) {
System.out.println((i + 1) + ". " + emergencyContacts.get(i).getFirstName() + " "
+ emergencyContacts.get(i).getLastName());
}
int index = scan.nextInt();
int num = index - 1;
emergencyContacts.remove(num);
scan.nextLine();
} else
System.out.println("Please enter a valid number");
return emergencyContacts;
}
/**
* edits doctor information
*
* @param doctor
* @return
*/
private Contact editDoctor(Contact doctor) {
boolean run = true;
while (run) {
System.out.println("Change: \n1. First Name\n2. Last Name\n3. Phone Number\n4. Email Address\n5. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
doctor.setFirstName(get("First Name"));
break;
case 2:
doctor.setLastName(get("Last Name"));
break;
case 3:
doctor.setPhoneNumber(get("Phone Number"));
break;
case 4:
doctor.setEmailAddress(get("Email Address"));
break;
case 5:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
}
return doctor;
}
/**
* The screen counselors see when they login
*/
private void counselorScreen() {
welcomeCounselorScreen();
boolean run = true;
while (run) {
counselorOptions();
int option = scan.nextInt();
scan.nextLine();
clear();
switch (option) {
case 1:
System.out.println(facade.viewCounselorProfile());
break;
case 2:
editCounselor();
break;
case 3:
viewGroup();
break;
case 4:
viewGroupInfo();
break;
case 5:
String camp = get("Camp");
int week = Integer.parseInt(get("Week Number"));
System.out.println(facade.getSchedule(camp, week));
UUID id = facade.getGroupUUID(camp, week);
DataWriter.writeGroupSchedule(id);
break;
case 6:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
pause();
}
}
/**
* Displays all campers in the counselors group
*/
private void viewGroup() {
String camp = get("Camp");
int week = Integer.parseInt(get("Week Number"));
ArrayList<Camper> campers = facade.getGroupCampers(camp, week);
UUID id = facade.getGroupUUID(camp, week);
for (Camper camper : campers) {
System.out.println(camper.toStringBrief() + "\n");
}
DataWriter.writeRosterToTxt(id);
}
/**
* Displays teh information of all campers in the group
*/
private void viewGroupInfo() {
String camp = get("Camp");
int week = Integer.parseInt(get("Week Number"));
ArrayList<Camper> campers = facade.getGroupCampers(camp, week);
UUID id = facade.getGroupUUID(camp, week);
for (Camper camper : campers) {
System.out.println(camper.toStringFull() + "\n");
}
DataWriter.writeDetailedRosterToTxt(id);
}
/**
* Prints out the counselors options
*/
private void counselorOptions() {
System.out.println("1. View My Profile\n2. Edit My Profile\n3. View Campers\n4. View Camper Information" +
"\n5. View My Schedule\n6. Logout");
}
private void editCounselor() {
boolean run = true;
while (run) {
System.out.println("What would you like to edit:\n1. First Name \n2. Last Name" +
"\n3. Home Address\n4. Date of Birth\n5. Phone Number" +
"\n6. Emergency Contacts\n7. Doctor Information\n8. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
String newfirstname = get("First Name");
facade.editCounselorFirstName(newfirstname);
break;
case 2:
String newlastname = get("Last Name");
facade.editCounselorLastName(newlastname);
break;
case 3:
String newhomeaddress = get("Home Address");
facade.editCounselorHomeAddress(newhomeaddress);
break;
case 4:
String newdob = get("Date of Birth(MM/DD/YYYY");
facade.editCounselorDateOfBirth(formatDate(newdob));
break;
case 5:
String newphonenumber = get("Phone Number");
facade.editCounselorPhoneNumber(newphonenumber);
break;
case 6:
facade.editCounselorEmergencyContacts(editEC(facade.getCurrentCounselor().getEmergencyContacts()));
break;
case 7:
facade.editCounselorDoctor(editDoctor(facade.getCurrentCounselor().getPediatrician()));
case 8:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
pause();
}
}
/**
* The screen directors see when the login
*/
private void directorScreen() {
welcomeDirectorScreen();
boolean run = true;
while (run) {
directorOptions();
int option = scan.nextInt();
scan.nextLine();
clear();
switch (option) {
case 1: // View My Profile
System.out.println(facade.viewDirectorProfile());
break;
case 2: // Edit My (director) Profile
editDirector();
break;
case 3: // Create new camp
createCamp();
break;
case 4: // View Activities
System.out.println("What camp would you like to see?");
System.out.println(facade.getActivities(scan.nextLine()));
break;
case 5: // Edit Activities
changeActivites();
break;
case 6: // View All counselors
System.out.println(facade.getCounselors());
break;
case 7: // View a Counselors Information
String firstName = get("Counselor's First Name");
String lastName = get("Counselor's Last Name");
System.out.println(facade.getCounselorList().getCounselorByName(firstName, lastName));
break;
case 8: // Remove Counselor
String campName = get("Camp");
String counselorname = get("Counselor First Name");
String counselorlname = get("Counselor Last Name");
facade.removeCounselor(counselorname, counselorlname, facade.getCampList().getCamp(campName));
break;
case 9: // View All Campers
System.out.println(facade.getCampers());
break;
case 10: // View A Camper
String camperName = get("Camper's First Name");
String camperlName = get("Camper's Last Name");
System.out.println(facade.getCamperList().getCamperByName(camperName, camperlName));
case 11: // Remove Camper
String campname = get("Camp");
String campername = get("Camper First Name");
String camperlname = get("Camper Last Name");
facade.removeCamper(campername, camperlname, facade.getCampList().getCamp(campname));
break;
case 12: // View Schedule
String camp = get("Camp");
int week = Integer.parseInt(get("Week Number"));
int group = Integer.parseInt(get("Group Number"));
System.out.println(facade.getSchedule(camp, week, group));
break;
case 13: // Logout
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
pause();
}
}
/**
* options on the directors homepage
*/
private void directorOptions() {
System.out.println(
"1. View My Profile\n2. Edit My Profile\n3. Create New Camp\n4. View Activities\n5. Edit Activites\n6. View All Counselors"
+
"\n7. View a Counselors Information\n8. Remove Counselor\n9. View All Campers\n10. View a Campers Information\n11. Remove Camper\n12. View Schedules"
+
"\n13. Logout");
}
/**
* edits the directors information
*/
private void editDirector() {
boolean run = true;
while (run) {
System.out.println("What would you like to edit:\n1. First Name \n2. Last Name" +
"\n3. Home Address\n4. Date of Birth\n5. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
String newfirstname = get("First Name");
facade.editDirectorFirstName(newfirstname);
break;
case 2:
String newlastname = get("Last Name");
facade.editDirectorLastName(newlastname);
break;
case 3:
String newhomeaddress = get("Home Address");
facade.editDirectorHomeAddress(newhomeaddress);
break;
case 4:
String newdob = get("Date of Birth(MM/DD/YYYY");
facade.editDirectorDateOfBirth(formatDate(newdob));
break;
case 5:
run = false;
break;
default:
System.out.println("Please enter a valid number");
break;
}
}
}
/**
* prompts dircetor for new camp information
*/
private void createCamp() {
int year = Integer.parseInt(get("Year of Camp"));
String name = get("Name of Camp");
String description = get("Short Description of Camp");
String weekString = get("Number of Weeks");
int weeknum = Integer.parseInt(weekString);
HashMap<Integer, Week> weeks = new HashMap<Integer, Week>();
for (int i = 1; i <= weeknum; i++) {
System.out.println("Week " + i + ": ");
Date startDate = formatDate(get("Start Date(MM/DD/YYYY)"));
Date endDate = formatDate(get("End Date(MM/DD/YYYY)"));
String theme = get("Theme");
Week week = new Week(theme, startDate, endDate, false);
Integer num = Integer.valueOf(i);
weeks.put(num, week);
}
ArrayList<Activity> activities = new ArrayList<>();
for (int i = 1; i <= 6; i++) {
System.out.println("Activity " + i);
String activityName = get("Name");
String activityDesc = get("Description");
String location = get("Location");
Activity activity = new Activity(activityName, location, activityDesc);
activities.add(activity);
}
facade.newCamp(name, description, year, activities, weeks);
/*
* for (int i = 0; i < weeknum; i++) {
* facade.generateSchedules(name, i, activities);
* }
*/
facade.generateSchedulesCamp(name, activities);
}
/**
* Changes activities for a given camp
*/
private void changeActivites() {
String camp = get("Which Camp would you like to change the activities for");
boolean run = true;
while (run) {
System.out.println("Would you like to: \n1. Edit Current Activites \n2. Delete Current Activites" +
"\n3. Add New Activities \n4. Quit");
int choice = scan.nextInt();
scan.nextLine();
switch (choice) {
case 1:
editActivities(camp);