-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirector.java
206 lines (179 loc) · 6.63 KB
/
Director.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
import java.util.ArrayList;
import java.util.UUID;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Director extends Person {
private LoginInfo userLogin;
private ArrayList<Camp> camps = new ArrayList<Camp>();
private String email;
public Director(String firstName, String lastName, Date dateOfBirth,
String homeAddress, String email, LoginInfo userLogin, ArrayList<Camp> camps) {
super(firstName, lastName, dateOfBirth, homeAddress);
this.camps = camps;
this.userLogin = userLogin;
this.email = email;
}
public Director(UUID uuid, String firstName, String lastName, Date dateOfBirth,
String homeAddress, String email, LoginInfo userLogin, ArrayList<Camp> camps) {
super(uuid, firstName, lastName, dateOfBirth, homeAddress);
this.camps = camps;
this.userLogin = userLogin;
this.email = email;
}
public LoginInfo getUserLogin() {
return userLogin;
}
public ArrayList<Camp> getCamps() {
return camps;
}
public String getEmail() {
return email;
}
public void setUserLogin(LoginInfo userLogin) {
this.userLogin = userLogin;
}
public void setEmail(String email) {
this.email = email;
}
public void setCamps(ArrayList<Camp> camps) {
this.camps = camps;
}
public ArrayList<Camp> getCamp() {
return camps;
}
public void addCamp(Camp camp) {
camps.add(camp);
}
public void removeCamper(String firstName, String lastName, Camp camp)
{
for(int w = 0; w < camp.getMasterSchedule().size(); w++)
{
for(int c = 0; c < camp.getMasterSchedule().get(w).getCampers().size(); c++)
{
if(camp.getMasterSchedule().get(w).getCampers().get(c).getFirstName().equals(firstName)
&& camp.getMasterSchedule().get(w).getCampers().get(c).getLastName().equals(lastName))
{
removeCamperFromGroups(camp.getMasterSchedule().get(w), camp.getMasterSchedule().get(w).getCampers().get(c));
camp.getMasterSchedule().get(w).getCampers().remove(c);
c = camp.getMasterSchedule().get(w).getCampers().size();
}
}
}
for(int c = 0; c < CamperList.getInstance().getCampers().size(); c++)
{
if(CamperList.getInstance().getCampers().get(c).getFirstName().equals(firstName)
&& CamperList.getInstance().getCampers().get(c).getLastName().equals(lastName))
{
CamperList.getInstance().getCampers().remove(c);
c = CamperList.getInstance().getCampers().size();
}
}
}
private boolean removeCamperFromGroups(Week week, Camper camperToBeRemoved)
{
for (Group g : week.getGroups())
{
for (int i = 0; i < g.getCampers().size(); i++)
{
if (g.getCampers().get(i).equals(camperToBeRemoved))
{
g.getCampers().remove(i);
return true;
}
}
}
return false;
}
public void removeCounselor(String firstName, String lastName, Camp camp)
{
for(int w = 0; w < camp.getMasterSchedule().size(); w++)
{
for(int c = 0; c < camp.getMasterSchedule().get(w).getCounselors().size(); c++)
{
if(camp.getMasterSchedule().get(w).getCounselors().get(c).getFirstName().equals(firstName)
&& camp.getMasterSchedule().get(w).getCounselors().get(c).getLastName().equals(lastName))
{
for(int g = 0; g < camp.getMasterSchedule().get(w).getGroups().size(); g++)
{
if(camp.getMasterSchedule().get(w).getGroups().get(g).getCounselor().equals
(camp.getMasterSchedule().get(w).getCounselors().get(c)))
{
camp.getMasterSchedule().get(w).getGroups().get(g).setCounselor(null);
g = camp.getMasterSchedule().get(w).getGroups().size();
}
}
camp.getMasterSchedule().get(w).getCounselors().remove(c);
c = camp.getMasterSchedule().get(w).getCounselors().size();
}
}
}
for(int c = 0; c < CounselorList.getInstance().getCounselors().size(); c++)
{
if(CounselorList.getInstance().getCounselors().get(c).getFirstName().equals(firstName)
&& CounselorList.getInstance().getCounselors().get(c).getLastName().equals(lastName))
{
CounselorList.getInstance().getCounselors().remove(c);
c = CounselorList.getInstance().getCounselors().size();
}
}
}
public String getGroupSchedule(int campNumber, Integer weekNumber, int groupNumber) {
return camps.get(campNumber).getMasterSchedule().get(weekNumber).getGroups().get(groupNumber).printSchedule();
}
public String getWeekSchedule(int campNumber, Integer weekNumber) {
return camps.get(campNumber).getMasterSchedule().get(weekNumber).viewSchedule();
}
public String viewActivities(int year) {
String temp = new String();
for (Camp c : camps) {
if (c.getYear() == year) {
for (Activity a : c.getActivitiesArrayList()) {
temp = temp + a.toString() + "\n";
}
return temp;
}
}
return null;
}
public void addActivity(int year, Activity activity) {
for (Camp c : camps) {
if (c.getYear() == year) {
c.getActivitiesArrayList().add(activity);
break;
}
}
}
public void removeActivity(int year, Activity activity) {
for (Camp c : camps) {
if (c.getYear() == year) {
for (int i = 0; i < c.getActivitiesArrayList().size(); i++) {
if (c.getActivitiesArrayList().get(i).equals(activity)) {
c.getActivitiesArrayList().remove(i);
i = c.getActivitiesArrayList().size();
}
}
break;
}
}
}
public String viewCounselorInfo(String firstName, String lastName) {
Counselor temp;
temp = CounselorList.getInstance().getCounselorByName(firstName, lastName);
if (temp == null)
return null;
else
return temp.toString();
}
public String toString() {
String temp = new String();
temp = "\nDirector: " + firstName + " " + lastName + "\nUsername: "
+ userLogin.getUserName() + "\nDate of Birth: "
+ formatDate(dateOfBirth) + "\nAddress: " + homeAddress + "\n";
return temp;
}
private String formatDate(Date d)
{
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
return formatter.format(d);
}
}