在不同的业务场景下,Employee类可以用于表示和处理员工相关的信息。以下是一些常见的业务场景及其在Employee类中的应用:
public class Employee {
private String name;
private String position;
private String department;
private LocalDate hireDate;
private double salary;
// 构造函数、getter和setter方法
public void promote(String newPosition) {
this.position = newPosition;
}
public void increaseSalary(double percentage) {
this.salary *= (1 + percentage / 100);
}
public void terminate() {
// 更新员工状态或执行其他辞职相关操作
}
}
public class Employee {
private String name;
private LocalTime workStartTime;
private LocalTime workEndTime;
private List<Leave> leaves;
// 构造函数、getter和setter方法
public void clockIn() {
this.workStartTime = LocalTime.now();
}
public void clockOut() {
this.workEndTime = LocalTime.now();
}
public void requestLeave(LocalDate startDate, LocalDate endDate, String reason) {
Leave leave = new Leave(startDate, endDate, reason);
this.leaves.add(leave);
}
}
public class Employee {
private String name;
private List<Project> projects;
private Map<Project, Task> tasks;
// 构造函数、getter和setter方法
public void assignToProject(Project project) {
this.projects.add(project);
}
public void assignTask(Project project, Task task) {
this.tasks.put(project, task);
}
public void completeTask(Project project) {
this.tasks.remove(project);
}
}
public class Employee {
private String name;
private double baseSalary;
private double bonus;
private double socialSecurity;
// 构造函数、getter和setter方法
public double calculateTotalSalary() {
return this.baseSalary + this.bonus - this.socialSecurity;
}
public void adjustSalary(double percentage) {
this.baseSalary *= (1 + percentage / 100);
}
}
这些只是一些常见的业务场景示例,实际应用中可能会根据具体需求进行更多的扩展和定制。