-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContractEmployee.java
More file actions
41 lines (35 loc) · 1.27 KB
/
ContractEmployee.java
File metadata and controls
41 lines (35 loc) · 1.27 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
public class ContractEmployee extends Employee implements RaiseSalary, ExtendContractDuration {
public int contractDuration;
public double raise;
ContractEmployee(String name, double salary, int contractDuration) {
super(name, salary);
this.contractDuration = contractDuration;
}
@Override
public void askRaise(double raise) {
this.raise = raise;
}
@Override
public double calculateSalary() {
return (this.salary + this.raise) * this.getSalaryMultiplier();
}
@Override
public void extendContract(int duration) {
this.contractDuration = this.contractDuration + duration;
}
@Override
public String toString() {
return "[" + this.employeeId + "] " + this.name + " | Salary : " + String.format("%.0f", this.calculateSalary()) + " | Kenaikan : " + String.format("%.0f", this.raise) + " | Kontrak : " + this.contractDuration;
}
private double getSalaryMultiplier() {
if (this.contractDuration <= 6) {
return 1.0;
} else if (this.contractDuration <= 12) {
return 1.5;
} else if (this.contractDuration > 12) {
return 2.0;
} else {
return 1.0;
}
}
}