-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employers.java
66 lines (65 loc) · 1.91 KB
/
Employers.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
import java.util.ArrayList;
import java.util.UUID;
/**
* @author Anton, Christian, Kylie, Jack
*/
/**
* Creating and Intializing ArrayList of type Employer
*/
public class Employers {
private static Employers employers = null;
private static ArrayList<Employer> employerList = new ArrayList<>();
/**
* Calling the dataLoader to fill employerList with employee information
*/
private Employers() {
employerList = DataLoader.getEmployers();
}
/**
* checking to see if there are employers if not a new one is created
* @return
*/
public static Employers getInstance() {
if (employers == null) {
employers = new Employers();
}
return employers;
}
public static ArrayList<Employer> getEmployers() {
return employerList;
}
/**
* Adding a Employer to the ArrayList of Employees with specific paramifications
* @param id
* @param email
* @param username
* @param password
* @param companyName
* @param description
*/
public static void addEmployer(UUID id, String email, String username, String password, String companyName, String description) {
employerList.add(new Employer(id,email,username,password,companyName,description));
}
/**
* writing all employer information to the JSON in datawriter
*/
public void logout() {
DataWriter.saveEmployer();
}
public static boolean haveEmployer(String userName) {
for(Employer employer: employerList ) {
if(employer.getUsername().equals(userName)) {
return true;
}
}
return false;
}
public static Employer getEmployer(String userName) {
for(Employer employer : employerList ) {
if(employer.getUsername().equals(userName)) {
return employer;
}
}
return null;
}
}