Repository navigation
Expand file tree
/
Copy pathCaseList.java
More file actions
137 lines (123 loc) · 3.54 KB
/
Copy pathCaseList.java
File metadata and controls
137 lines (123 loc) · 3.54 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
import java.util.ArrayList;
import java.util.UUID;
/**
* An Object representing a List of Cases.
* @author Code Gods
*/
public class CaseList {
private ArrayList<Case> caseList;
private static CaseList caseListObj=null;
private ArrayList<Witness> witnesses = new ArrayList<Witness>();
private ArrayList<Criminal> criminals = new ArrayList<Criminal>();
private ArrayList<Victim> victims = new ArrayList<Victim>();
private ArrayList<Suspect> suspects = new ArrayList<Suspect>();
private ArrayList<PersonOfInterest> pois = new ArrayList<PersonOfInterest>();
private ArrayList<Evidence> evidences = new ArrayList<Evidence>();
/**
* Default Constructor. Utilizes DataReader to initialize cases from JSON.
*/
public CaseList() {
this.caseList = DataReader.loadCase();
}
/**
* Returns the current instance of CaseList.
* @return The current instance of CaseList.
*/
public static CaseList getInstance() {
if(caseListObj == null) {
caseListObj = new CaseList();
}
return caseListObj;
}
/**
* Returns all cases currently in the application.
* @return All Cases in the application.
*/
public ArrayList<Case> getCases() {
return caseList;
}
/**
* Adds a case to the Case List.
* @param newCase The Case to be added.
*/
public void addCase(Case newCase) {
if(newCase!=null) {
caseList.add(newCase);
}
}
/**
* Adds a Witness to the Case List
* @param newWitness The witness to be added.
*/
public void addWitness(Witness newWitness) {
if(newWitness!=null) {
witnesses.add(newWitness);
}
}
/**
* Adds a Criminal to the Case List.
* @param newCriminal The Criminal to be added.
*/
public void addCriminal(Criminal newCriminal) {
if(newCriminal!=null) {
criminals.add(newCriminal);
}
}
/**
* Adds a Victim to the Case List.
* @param newVictim The Victim to be added.
*/
public void addVictim(Victim newVictim) {
if(newVictim!=null) {
victims.add(newVictim);
}
}
/**
* Adds a Suspect to the Case List.
* @param newSuspect The Suspect to be added.
*/
public void addSuspect(Suspect newSuspect) {
if(newSuspect!=null) {
suspects.add(newSuspect);
}
}
/**
* Adds a Person of Interest to the Case List.
* @param newPOI The Person of Interest to be added.
*/
public void addPOI(PersonOfInterest newPOI) {
if(newPOI!=null) {
pois.add(newPOI);
}
}
/**
* Adds a piece of Evidence to the Case List.
* @param evidence The Evidence to be added.
*/
public void addEvidence(Evidence evidence){
if(evidence!=null){
evidences.add(evidence);
}
}
/**
* Finds a Case stored in the case list.
* @param id The ID of the Case being searched up.
* @return The Case that was found. Returns null if none were found.
*/
public Case findCase(UUID id){
for(int i=0;i<caseList.size();i++){
if(caseList.get(i).getCaseID().equals(id)){
return caseList.get(i);
}
}
return null;
}
/**
* Prints out to the console the case list in a human readable format.
*/
public void print(){
for(int i=0;i<caseList.size();i++){
System.out.println(caseList.get(i).toString());
}
}
}