Zoom
aid: int
a name: String
□ salary: double
Employee
a department: String
• Employee(id: int, name: String.
salary: double, department: String)
getid(): int
getName(): String
.getSalary(): double
getDepartment(): String
setName(n: String): void
.setSalary(s: double): void
.setDepartment(d: String): void
compareTo(other: Employee): int
toString(): String
Base on given class diagram, create all interface and class
1. Class Employee
•
Declare the fields of the class.
•
Constructor: initialize the fields with values.

Getter methods for the fields.

Setter methods for the fields.
int compareTo(Employee other): defines the natural order by name (case-insensitive).
String toString(): return a string in the specified format id-name-salary-department
2. Interface Employee Management

void add(Employee e); - add a new employee.
void update(Employee e);-replace an existing employee by ID.
• List<Employee> listAll(); return an unmodifiable or copied list of employees.
• List<Employee> sortByName(); return an unmodifiable or copied list of employees ordered
by name.
3. Class InMemoryEmployee Management
• Declare the fields of the class.

void add(Employee e)
+ 100%
Close