-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternEmployee.java
More file actions
36 lines (31 loc) · 1.1 KB
/
InternEmployee.java
File metadata and controls
36 lines (31 loc) · 1.1 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
public class InternEmployee extends Employee implements ExtendContractDuration {
public int contractDuration;
public double raise;
InternEmployee(String name, double salary, int contractDuration) {
super(name, salary);
this.contractDuration = contractDuration;
}
@Override
public double calculateSalary() {
return this.salary * 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()) + " | Kontrak : " + this.contractDuration + " Bulan";
}
private double getSalaryMultiplier() {
if (this.contractDuration <= 6) {
return 1.0;
} else if (this.contractDuration <= 12) {
return 1.25;
} else if (this.contractDuration > 12) {
return 1.5;
} else {
return 1.0;
}
}
}