Repository navigation
Expand file tree
/
Copy pathPersonList.java
More file actions
279 lines (254 loc) · 8.41 KB
/
Copy pathPersonList.java
File metadata and controls
279 lines (254 loc) · 8.41 KB
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
import java.util.ArrayList;
import java.util.UUID;
public class PersonList {
private ArrayList<Criminal> criminalList = new ArrayList<Criminal>();
private ArrayList<Witness> witnessList = new ArrayList<Witness>();
private ArrayList<Suspect> suspectList = new ArrayList<Suspect>();
private ArrayList<Victim> victimList = new ArrayList<Victim>();
private ArrayList<PersonOfInterest> poiList = new ArrayList<PersonOfInterest>();
private static PersonList personList = null;
/**
* default constructor
*/
private PersonList() {
this.criminalList = DataReader.loadCriminal();
this.witnessList = DataReader.loadWitness();
this.suspectList = DataReader.loadSuspect();
this.victimList = DataReader.loadVictim();
this.poiList = DataReader.loadPOI();
}
/**
* making an instance of the personList
*/
public static PersonList getInstance() {
if(personList == null) {
personList = new PersonList();
}
return personList;
}
/**
*
* @param criminal takes in the made Criminal
* adds the criminal to the criminal list
*/
public void addCriminal(Criminal criminal){
criminalList.add(criminal);
}
/**
* @param witness takes in the made witness
* adds the witness to the witness list
*/
public void addWitness(Witness witness){
witnessList.add(witness);
}
/**
*
* @param suspect takes in the made suspect
* adds the suspect to the suspect list
*/
public void addSuspect(Suspect suspect){
suspectList.add(suspect);
}
/**
*
* @param victim takes in the made victim
* adds the victim to the victim list
*/
public void addVictim(Victim victim){
victimList.add(victim);
}
/**
*
* @param poi takes in the made POI
* adds the poi to the poi list
*/
public void addPOI(PersonOfInterest poi){
poiList.add(poi);
}
/**
*
* @param id takes in the unique person id
* @return searches through everyone in the person list, so criminals, witnesses, suspects, victims, and pois, and returns
* the person with the matching UUID
*/
public Person findPerson(UUID id){
//id = Person.getUUID();
for (int i = 0; i < criminalList.size(); i++) {
if(criminalList.get(i).getUUID().equals(id)) {
return criminalList.get(i);
}
}
for (int i = 0; i < witnessList.size(); i++) {
if(witnessList.get(i).getUUID().equals(id)) {
return witnessList.get(i);
}
}
for (int i = 0; i < suspectList.size(); i++) {
if(suspectList.get(i).getUUID().equals(id)) {
return suspectList.get(i);
}
}
for (int i = 0; i < victimList.size(); i++) {
if(victimList.get(i).getUUID().equals(id)) {
return victimList.get(i);
}
}
for (int i = 0; i < poiList.size(); i++) {
if(poiList.get(i).getUUID().equals(id)) {
return poiList.get(i);
}
}
return null;
}
/**
* @param name takes in the persons name
* @return returns any person in the personList with a matching name
*/
public Person findPerson(String name){
for (int i = 0; i < criminalList.size(); i++) {
String fullName = criminalList.get(i).getFirstName() + criminalList.get(i).getLastName();
if(fullName.toLowerCase().contains(name)) {
return criminalList.get(i);
}
}
for (int i = 0; i < witnessList.size(); i++) {
String fullName = witnessList.get(i).getFirstName() + witnessList.get(i).getLastName();
if(fullName.toLowerCase().contains(name)) {
return witnessList.get(i);
}
}
for (int i = 0; i < suspectList.size(); i++) {
String fullName = suspectList.get(i).getFirstName() + suspectList.get(i).getLastName();
if(fullName.toLowerCase().contains(name)) {
return suspectList.get(i);
}
}
for (int i = 0; i < victimList.size(); i++) {
String fullName = victimList.get(i).getFirstName() + victimList.get(i).getLastName();
if(fullName.toLowerCase().contains(name)) {
return victimList.get(i);
}
}
for (int i = 0; i < poiList.size(); i++) {
String fullName = poiList.get(i).getFirstName() + poiList.get(i).getLastName();
if(fullName.toLowerCase().contains(name)) {
return poiList.get(i);
}
}
return null;
}
/**
* @param firstName takes in the persons first name
* @return returns a person in the personList with a matching first name
*/
public Person findPersonFirst(String firstName){
for (int i = 0; i < criminalList.size(); i++) {
String Firstname = criminalList.get(i).getFirstName();
if(Firstname.toLowerCase().contains(firstName)) {
return criminalList.get(i);
}
}
for (int i = 0; i < witnessList.size(); i++) {
String Firstname = witnessList.get(i).getFirstName();
if(Firstname.toLowerCase().contains(firstName)) {
return witnessList.get(i);
}
}
for (int i = 0; i < suspectList.size(); i++) {
String Firstname = suspectList.get(i).getFirstName();
if(Firstname.toLowerCase().contains(firstName)) {
return suspectList.get(i);
}
}
for (int i = 0; i < victimList.size(); i++) {
String Firstname = victimList.get(i).getFirstName();
if(Firstname.toLowerCase().contains(firstName)) {
return victimList.get(i);
}
}
for (int i = 0; i < poiList.size(); i++) {
String Firstname = poiList.get(i).getFirstName();
if(Firstname.toLowerCase().contains(firstName)) {
return poiList.get(i);
}
}
return null;
}
/**
*
* @param personID takes in the UUID
* @return returns the witness with a matching UUID
*/
public Witness findWitness(UUID personID){
for(int i = 0; i < witnessList.size(); i++){
String temp = witnessList.get(i).getUUID().toString();
if(temp.equals(personID.toString())){
return witnessList.get(i);
}
}
return null;
}
/**
* @param personID takes in the UUID
* @return returns the suspect with the matching UUID
*/
public Suspect findSuspect(UUID personID){
for(int i = 0; i < suspectList.size(); i++){
String temp = suspectList.get(i).getUUID().toString();
if(temp.equals(personID.toString())){
return suspectList.get(i);
}
}
return null;
}
/**
* return the arrayList criminalList
*/
public ArrayList<Criminal> getCriminals() {
return criminalList;
}
/**
* returns the arrayList suspectList
*/
public ArrayList<Suspect> getSuspects() {
return suspectList;
}
/**
* returns the arrayList witnessList
*/
public ArrayList<Witness> getWitnesses() {
return witnessList;
}
/**
* returns the arrayList victimList
*/
public ArrayList<Victim> getVictims() {
return victimList;
}
/**
* returns the arrayList poiList
*/
public ArrayList<PersonOfInterest> getPersonsOfInterests() {
return poiList;
}
/**
* prints the criminal, witness, victim, suspect, and poi lists
*/
public void print(){
for(int i=0;i<criminalList.size();i++){
System.out.println(criminalList.get(i).toString());
}
for (int i=0;i<witnessList.size();i++){
System.out.println(witnessList.get(i).toString());
}
for(int i=0;i<suspectList.size();i++){
System.out.println(suspectList.get(i).toString());
}
for (int i=0;i<victimList.size();i++){
System.out.println(victimList.get(i).toString());
}
for (int i=0;i<poiList.size();i++){
System.out.println(poiList.get(i).toString());
}
}
}