-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeManager.java
More file actions
94 lines (71 loc) · 2.38 KB
/
EmployeeManager.java
File metadata and controls
94 lines (71 loc) · 2.38 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
import java.util.ArrayList;
import java.util.List;
class EmployeeManager implements Manageable<Employee> {
private List<Employee> employeeList;
public EmployeeManager() {
// Initialize the employeeList as an empty list
employeeList = new ArrayList<>();
}
@Override
public void add(Employee employee) {
employeeList.add(employee);
System.out.println("[+] Employee added: " + employee.getEmployeeID() + " " + employee.getFirstName() + " " + employee.getLastName());
}
@Override
public void update(Employee employee) {
// Assuming employee information can be updated based on some criteria, implement the update logic here.
// You might want to find the employee in the list and update their information.
// No need to implement this method in this example.
}
@Override
public void delete(Employee employee) {
employeeList.remove(employee);
System.out.println("[-] Employee deleted: " + employee.getEmployeeID() + " " + employee.getFirstName() + " " + employee.getLastName());
}
@Override
public List<Employee> list() {
return employeeList;
}
}
class Employee {
private String employeeID;
private String firstName;
private String lastName;
private String department;
public Employee(String employeeID, String firstName, String lastName, String department) {
this.employeeID = employeeID;
this.firstName = firstName;
this.lastName = lastName;
this.department = department;
}
public String getEmployeeID() {
return employeeID;
}
public void setEmployeeID(String employeeID) {
this.employeeID = employeeID;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Override
public String toString() {
return "ID: " + employeeID + "\n" +
"Name: " + firstName + " " + lastName + "\n" +
"Department: " + department + "\n";
}
}