在不同的業務場景下,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);
}
}
這些只是一些常見的業務場景示例,實際應用中可能會根據具體需求進行更多的擴展和定制。