forked from OrlovAlexander85/Criminal_Intent_2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrimeLab.java
44 lines (34 loc) · 930 Bytes
/
CrimeLab.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
package ru.orlovph.criminalintent2020;
import android.content.Context;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
// Singleton class - a class that allows only one
// instance of itself to be created
public class CrimeLab {
private static CrimeLab sCrimeLab;
private List<Crime> mCrimes;
public static CrimeLab get(Context context) {
if (sCrimeLab == null) {
sCrimeLab = new CrimeLab(context);
}
return sCrimeLab;
}
private CrimeLab(Context context) {
mCrimes = new ArrayList<>();
}
public void addCrime(Crime crime){
mCrimes.add(crime);
}
public List<Crime> getCrimes(){
return mCrimes;
}
public Crime getCrime(UUID id){
for(Crime crime: mCrimes){
if (crime.getId().equals(id)){
return crime;
}
}
return null;
}
}