-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCampFacade.java
723 lines (660 loc) · 19.4 KB
/
CampFacade.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
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
public class CampFacade {
private CampList campList;
private CamperList camperList;
private UserList userList;
private CounselorList counselorList;
private DirectorList directorList;
private User currentUser;
private Counselor currentCounselor;
private Director currentDirector;
/**
* Creates the Camp facade with all of the instances of the lists
*/
public CampFacade() {
campList = CampList.getInstance();
camperList = CamperList.getInstance();
userList = UserList.getInstance();
counselorList = CounselorList.getInstance();
directorList = DirectorList.getInstance();
}
/**
* Returns the current user that is logged in
*
* @return
*/
public User getCurrentUser() {
return currentUser;
}
/**
* Returns the current counselor that is logged in
*
* @return
*/
public Counselor getCurrentCounselor() {
return currentCounselor;
}
/**
* Returns the current director that is logged in
*
* @return
*/
public Director getCurrentDirector() {
return currentDirector;
}
/**
* returns all camps
*
* @return all camps
*/
public CampList getCampList() {
return campList;
}
public String getCamps() {
String camps = "";
for (Camp camp : campList.getCamps()) {
camps += camp.getName() + "\n";
}
return camps;
}
public String getCampers() {
String campers = "";
for (Camper camper : camperList.getCampers()) {
campers += camper.getFirstName() + " " + camper.getLastName() + "\n";
}
return campers;
}
/**
* Checks to see if login information exists
*
* @param userLogin
* @return
*/
public int Login(LoginInfo userLogin) {
if (directorList.haveDirector(userLogin)) {
currentDirector = directorList.getDirectorByUserName(userLogin.getUserName());
return 1;
}
if (userList.haveUser(userLogin)) {
currentUser = userList.getUserByUserName(userLogin.getUserName());
// num = 2;
return 2;
}
if (counselorList.haveCounselor(userLogin)) {
currentCounselor = counselorList.getCounselorByUserName(userLogin.getUserName());
return 3;
}
return 0;
}
/**
* Adds a user
*
* @param firstName
* @param lastName
* @param doB
* @param homeAddress
* @param loginInfo
* @param campers
*/
public void addUser(String firstName, String lastName, Date doB, String homeAddress, LoginInfo loginInfo,
ArrayList<Camper> campers) {
User user = new User(firstName, lastName, doB, homeAddress, loginInfo, campers);
userList.addUser(user);
}
/**
* Adds a camper
*
* @param firstName
* @param lastName
* @param homeAddress
* @param doB
* @param sex
* @param medications
* @param allergies
* @param emergencyContacts
* @param pediatrician
* @return
*/
public Camper addCamper(String firstName, String lastName, String homeAddress, Date doB, Sex sex,
ArrayList<Medication> medications, ArrayList<String> allergies,
ArrayList<Contact> emergencyContacts, Contact pediatrician) {
Camper camper = new Camper(firstName, lastName, homeAddress, doB, sex, medications, allergies,
emergencyContacts, pediatrician);
camperList.addCamper(camper);
return camper;
}
/**
* Adds a counselor
*
* @param firstName
* @param lastName
* @param phoneNumber
* @param emailAddress
* @param homeAddress
* @param doB
* @param emergencyContacts
* @param pediatrician
* @param loginInfo
*/
public Counselor addCounselor(String firstName, String lastName, String phoneNumber, String emailAddress,
String homeAddress, Date doB, ArrayList<Contact> emergencyContacts, Contact pediatrician,
LoginInfo loginInfo) {
Counselor counselor = new Counselor(firstName, lastName, phoneNumber, emailAddress, homeAddress, doB,
emergencyContacts, pediatrician, loginInfo);
counselorList.addCounselor(counselor);
// call that one thing
return counselor;
}
/**
* changes campers first name
*
* @param camper
* @param firstName
*/
public void editCamperFirstName(String camper, String firstName) {
Camper currentCamper = currentUser.getCampers().get(0);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setFirstName(firstName);
camperList.saveCampers();
}
/**
* changes campers last name
*
* @param camper
* @param lastName
*/
public void editCamperLastName(String camper, String lastName) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setLastName(lastName);
camperList.saveCampers();
}
/**
* changes campers home address
*
* @param camper
* @param homeAddress
*/
public void editCamperHomeAddress(String camper, String homeAddress) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setHomeAddress(homeAddress);
camperList.saveCampers();
}
/**
* changes campers date of birth
*
* @param camper
* @param dateOfBirth
*/
public void editCamperDateOfBirth(String camper, Date dateOfBirth) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setDateOfBirth(dateOfBirth);
camperList.saveCampers();
}
/**
* changes campers sex
*
* @param camper
* @param sex
*/
public void editCamperSex(String camper, Sex sex) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setSex(sex);
camperList.saveCampers();
}
/**
* edits campers allergy list
*
* @param camper
* @param allergies
*/
public void editCamperAllergies(String camper, ArrayList<String> allergies) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setAllergies(allergies);
camperList.saveCampers();
}
/**
* edits campers emergency contacts list
*
* @param camper
* @param contacts
*/
public void editCamperEmergencyContacts(String camper, ArrayList<Contact> contacts) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setEmergencyContacts(contacts);
camperList.saveCampers();
}
/**
* edits campers doctor
*
* @param camper
* @param doctor
*/
public void editCamperPediatrician(String camper, Contact doctor) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else
currentCamper.setPediatrician(doctor);
camperList.saveCampers();
}
/**
* edits campers week
*
* @param camper
* @param doctor
*/
public void editCamperWeek(String camper, int week, String camp) {
Camper currentCamper = currentUser.getCamper(camper);
if (currentCamper == null)
System.out.println("There is no camper with that name");
else {
currentCamper.selectWeek(campList.getCamp(camp), week);
currentCamper.addWeek(week);
}
camperList.saveCampers();
}
/**
* changes users first name
*
* @param firstName
*/
public void editUserFirstName(String firstName) {
currentUser.setFirstName(firstName);
userList.saveUsers();
}
/**
* changes users last name
*
* @param lastName
*/
public void editUserLastName(String lastName) {
currentUser.setLastName(lastName);
userList.saveUsers();
}
/**
* chnages users home address
*
* @param homeAddress
*/
public void editUserHomeAddress(String homeAddress) {
currentUser.setHomeAddress(homeAddress);
userList.saveUsers();
}
/**
* changes users date of birth
*
* @param dateOfBirth
*/
public void editUserDateOfBirth(Date dateOfBirth) {
currentUser.setDateOfBirth(dateOfBirth);
userList.saveUsers();
}
/**
* changes counselors first name
*
* @param firstName
*/
public void editCounselorFirstName(String firstName) {
currentCounselor.setFirstName(firstName);
counselorList.saveCounselor();
}
/**
* changes counselors last name
*
* @param lastName
*/
public void editCounselorLastName(String lastName) {
currentCounselor.setLastName(lastName);
counselorList.saveCounselor();
}
/**
* changes chounselors home address
*
* @param homeAddress
*/
public void editCounselorHomeAddress(String homeAddress) {
currentCounselor.setHomeAddress(homeAddress);
counselorList.saveCounselor();
}
/**
* changes counselors phone number
*
* @param phoneNumber
*/
public void editCounselorPhoneNumber(String phoneNumber) {
currentCounselor.setPhoneNumber(phoneNumber);
counselorList.saveCounselor();
}
/**
* changes counselors date of birth
*
* @param dob
*/
public void editCounselorDateOfBirth(Date dob) {
currentCounselor.setDateOfBirth(dob);
counselorList.saveCounselor();
}
/**
* edits counselors emergency contacts list
*
* @param contacts
*/
public void editCounselorEmergencyContacts(ArrayList<Contact> contacts) {
currentCounselor.setEmergencyContacts(contacts);
counselorList.saveCounselor();
}
/**
* edits counselors doctor
*
* @param doctor
*/
public void editCounselorDoctor(Contact doctor) {
currentCounselor.setPediatrician(doctor);
counselorList.saveCounselor();
}
/**
* returns true if they qualify for a discount
*
* @return
*/
public boolean qualifiesForDiscount() {
return currentUser.qualifiesForDiscount(campList, 1);
}
/**
* returns user profile
*
* @return
*/
public String viewUserProfile() {
return currentUser.viewUserProfile();
}
/**
* returns all of the campers a user has
*
* @return
*/
public String viewCampers() {
String campers = "";
for (Camper camper : currentUser.getCampers()) {
campers += camper.toStringBrief() + "\n" + camper.getWeeks() + "\n";
}
return campers;
}
/**
* returns a specific camper profile
*
* @param firstName
* @return
*/
public String viewCamperProfile(String firstName) {
return currentUser.viewCamperProfile(firstName);
}
/**
* returns counselors profile
*
* @return
*/
public String viewCounselorProfile() {
return currentCounselor.toString();
}
/**
* returns the directors profile
*
* @return
*/
public String viewDirectorProfile() {
return currentDirector.toString();
}
/**
* changes the directors first name
*
* @param firstName
*/
public void editDirectorFirstName(String firstName) {
currentDirector.setFirstName(firstName);
directorList.saveDirector();
}
/**
* changes the directors last name
*
* @param lastName
*/
public void editDirectorLastName(String lastName) {
currentDirector.setLastName(lastName);
directorList.saveDirector();
}
/**
* changes the directors home address
*
* @param homeAddress
*/
public void editDirectorHomeAddress(String homeAddress) {
currentDirector.setHomeAddress(homeAddress);
directorList.saveDirector();
}
/**
* changes tha directors date of birth
*
* @param dob
*/
public void editDirectorDateOfBirth(Date dob) {
currentDirector.setDateOfBirth(dob);
directorList.saveDirector();
}
/**
* Adds a new Camp to campList
*
* @param name
* @param desc
* @param weeks
* @param year
*/
public void newCamp(String name, String desc, int year, ArrayList<Activity> activites,
HashMap<Integer, Week> masterSchedule) {
Camp camp = new Camp(name, desc, masterSchedule, activites, year);
campList.addCamp(camp);
campList.saveCamps();
}
public void generateSchedules(String camp, int week, ArrayList<Activity> activities) {
campList.getCamp(camp).getWeek(week).generateSchedules(activities);
campList.saveCamps();
}
public void generateSchedulesCamp(String camp, ArrayList<Activity> activities) {
for (int w = 0; w < campList.getCamp(camp).getMasterSchedule().size(); w++) {
campList.getCamp(camp).getWeek(w).generateSchedules(activities);
}
}
/**
* Initializes each week of a camp
*
* @param camp
* @param week
* @param startDate
* @param endDate
* @param theme
*/
// setWeek doesn't work. theme and dates are null
public void setWeek(String name, int weekNum, Date startDate, Date endDate, String theme) {
Camp camp = campList.getCamp(name);
Week week = campList.getCamp(name).getWeek(weekNum);
week.setStartDate(startDate);
week.setEndDate(endDate);
week.setTheme(theme);
camp.getWeeks().add(week);
campList.addCamp(camp);
campList.saveCamps();
/*
* see how to write new arrays to JSON.
* adding a new camper for parent works. see if you can mimick this.
*/
}
/**
* returns the calendar
*
* @return
*/
public String viewCalendar() {
return null;
}
/**
* returns all the activities the camp offers
*
* @param campName
* @return
*/
public String getActivities(String campName) {
for (Camp camp : campList.getCamps()) {
if (camp.getName().equals(campName))
return camp.getActivities();
}
return "This camp does not exist";
}
/**
* sets activities for a camp
*
* @param camp
* @param activities
*/
public void setActivities(String camp, ArrayList<Activity> activities) {
campList.getCamp(camp).setActivities(activities);
campList.saveCamps();
}
/**
* returns all the weeks the camp offers
*
* @param campName
* @return
*/
public ArrayList<Week> getWeeks(String campName) {
for (Camp camp : campList.getCamps()) {
if (camp.getName().equals(campName))
return camp.getWeeks();
}
return null;
}
/**
* returns a counselors campers
*
* @param camp
* @param week
* @return
*/
public ArrayList<Camper> getGroupCampers(String camp, int weekNum) {
for (HashMap.Entry<Integer, Week> entry : campList.getCamp(camp).getMasterSchedule().entrySet()) {
Integer num = entry.getKey();
Integer passedNum = Integer.valueOf(weekNum);
Week week = entry.getValue();
if (num == passedNum) {
ArrayList<Camper> campers = new ArrayList<Camper>();
campers = week.getGroups().get(weekNum - 1).getCampers();
return campers;
}
}
return null;
}
public UUID getGroupUUID(String camp, int weekNum) {
for (HashMap.Entry<Integer, Week> entry : campList.getCamp(camp).getMasterSchedule().entrySet()) {
Integer num = entry.getKey();
Integer passedNum = Integer.valueOf(weekNum);
Week week = entry.getValue();
if (num == passedNum) {
return week.getGroups().get(weekNum - 1).getUuid();
}
}
return null;
}
/**
* returns a counselors schedule
*
* @param camp
* @param week
* @return
*/
public String getSchedule(String camp, int weekNum) {
/*
* print out a group's schedule
*/
System.out.println(campList.getCamp(camp).toString());
for (HashMap.Entry<Integer, Week> entry : campList.getCamp(camp).getMasterSchedule().entrySet()) {
Integer num = entry.getKey();
Integer passedNum = Integer.valueOf(weekNum);
Week week = entry.getValue();
if (num == passedNum) {
return week.getGroups().get(weekNum - 1).getSchedule().toString();
}
}
return null;
// return campList.getCamp(camp).getWeek(week -
// 1).getGroupByUUID(currentCounselor.getUUID()).printSchedule();
}
public String getSchedule(String camp, int weekNum, int groupNum) { // error here
System.out.println("Week Theme: " + campList.getCamp(camp).getWeek(weekNum - 1).getTheme());
Week week = campList.getCamp(camp).getWeek(weekNum - 1);
Group group = week.getGroupByNumber(groupNum - 1);
return group.printSchedule();
// return campList.getCamp(camp).getWeek(week - 1).getGroupByNumber(group -
// 1).printSchedule();
}
/**
* returns the camperlist
*
* @return
*/
public CamperList getCamperList() {
return camperList;
}
/**
* returns the counselorlist
*
* @return
*/
public CounselorList getCounselorList() {
return counselorList;
}
public String getCounselors() {
String counselors = new String();
counselors = "\nCounselors: \n";
for (Counselor c : counselorList.getCounselors()) {
counselors = counselors + c.getFirstName() + " " + c.getLastName() + "\n";
}
return counselors;
}
/**
* removes a camper from a week
*
* @param firstName
* @param lastName
* @param week
*/
public void removeCamper(String firstName, String lastName, Camp camp) {
currentDirector.removeCamper(firstName, lastName, camp);
camperList.saveCampers();
}
public void removeCounselor(String firstName, String lastName, Camp camp) {
currentDirector.removeCounselor(firstName, lastName, camp);
counselorList.saveCounselor();
}
}