-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamper.java
182 lines (157 loc) · 5.6 KB
/
Camper.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
import java.util.ArrayList;
import java.util.UUID;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.HashMap;
/**
* A class that defines a camper for the camp
*
*/
public class Camper extends Person {
private Sex sex;
private ArrayList<Medication> medications = new ArrayList<Medication>();
private ArrayList<String> allergies = new ArrayList<String>();
private ArrayList<Contact> emergencyContacts = new ArrayList<Contact>();
private Contact pediatrician;
private Date dateOfBirth;
private ArrayList<Integer> weeks;
/**
* The following attributes are needed to create an individual camper
*
* @param sex A string for their sex
* @param medicalInfo A string for their medical info
* @param emergencyContacts A list of the camper's emergency contacts
* @param pediatrician A contact for the camper's pediatrician
*/
public Camper(String firstName, String lastName, String homeAddress, Date dateOfBirth,
Sex sex, ArrayList<Medication> medications, ArrayList<String> allergies,
ArrayList<Contact> emergencyContacts, Contact pediatrician) {
super(firstName, lastName, dateOfBirth, homeAddress);
this.sex = sex;
this.medications = medications;
this.allergies = allergies;
this.emergencyContacts = emergencyContacts;
this.pediatrician = pediatrician;
this.dateOfBirth = dateOfBirth;
weeks = new ArrayList<>();
}
public Camper(UUID uuid, String firstName, String lastName, String homeAddress, Date dateOfBirth,
Sex sex, ArrayList<Medication> medications, ArrayList<String> allergies,
ArrayList<Contact> emergencyContacts, Contact pediatrician) {
super(uuid, firstName, lastName, dateOfBirth, homeAddress);
this.sex = sex;
this.medications = medications;
this.allergies = allergies;
this.emergencyContacts = emergencyContacts;
this.pediatrician = pediatrician;
this.dateOfBirth = dateOfBirth;
weeks = new ArrayList<>();
}
public Sex getSex() {
return sex;
}
public void setSex(Sex sex) {
this.sex = sex;
}
public ArrayList<Medication> getMedications() {
return medications;
}
public void setMedications(ArrayList<Medication> medications) {
this.medications = medications;
}
public ArrayList<String> getAllergies() {
return allergies;
}
public void setAllergies(ArrayList<String> allergies) {
this.allergies = allergies;
}
public ArrayList<Contact> getEmergencyContacts() {
return emergencyContacts;
}
public void setEmergencyContacts(ArrayList<Contact> emergencyContacts) {
this.emergencyContacts = emergencyContacts;
}
public Contact getPediatrician() {
return pediatrician;
}
public void setPediatrician(Contact pediatrician) {
this.pediatrician = pediatrician;
}
public void addWeek(int week) {
weeks.add(week);
}
public String getWeeks() {
String temp = "";
for (int i = 0; i < weeks.size(); i++) {
temp += "Week " + weeks.get(i) + "\n";
}
return temp;
}
/**
* A description of the camper in string form
* A to string for when a counselor wants to see info about the campers in their
* group
* @return A string description of the camper
*/
public String toStringBrief() {
return firstName + " " + lastName;
}
// when director or user wants to see camper information
public String toStringFull() {
String temp = "";
temp = "\nCamper: " + firstName + " " + lastName + "\nDate of Birth: " + formatDate(dateOfBirth)
+ "\nAddress: " + homeAddress + "\nSex: " + sex + "\nMedications: \n" + printMedication()
+ "\nAllergies: \n"
+ printAllergies() + "\nEmergency Contacts: \n" + printEmergencyContacts() + "\nPediatrician: \n"
+ pediatrician.toString() + "\n";
return temp;
}
private String formatDate(Date d) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
return formatter.format(d);
}
//helper methods for turning camper information into a string
private String printMedication() {
String temp = new String();
for (Medication m : medications) {
temp = temp + m.toString() + "\n";
}
return temp;
}
private String printEmergencyContacts() {
String temp = new String();
for (Contact c : emergencyContacts) {
temp = temp + c.toString() + "\n";
}
return temp;
}
private String printAllergies() {
String temp = new String();
for (String a : allergies) {
temp = temp + a.toString() + "\n";
}
return temp;
}
public String toString() {
return firstName + " " + lastName;
}
public boolean selectWeek(Camp camp, Integer weekNumber) {
if(getWeek(camp,weekNumber).isFull())
{
return false;
}
getWeek(camp,weekNumber).getCampers().add(this);
return true;
}
private Week getWeek(Camp camp, Integer weekNumber) {
Week week = new Week();
for (HashMap.Entry<Integer, Week> entry : camp.getMasterSchedule().entrySet()) {
Integer weekInt = entry.getKey();
Week thisWeek = entry.getValue();
if (weekNumber - 1 == weekInt) {
week = thisWeek;
}
}
return week;
}
}