forked from Santoshrt999/Java-Abstract-Class-and-Interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cashier.java
64 lines (53 loc) · 1.86 KB
/
Cashier.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public class Cashier extends AbstractStoreEmployee {
// Menambahkan variabel khusus untuk Cashier, jam kerja.
private double TheirOvertime;
// Konstruktor untuk Cashier
public Cashier(double numberOfHoursWorked, double hourlyRate, String storeDetails,
double basePay, String employeeName, double overtime) {
super(numberOfHoursWorked, hourlyRate, storeDetails, basePay, employeeName);
this.TheirOvertime = overtime;
}
public double getOvertime(){
return this.TheirOvertime;
}
// Implementasi dari method abstract di AbstractStoreEmployee
@Override
public double calculatePay() {
return super.getBasePay() + (super.getHourlyRate() * TheirOvertime) + bonusHour((int)getNumberOfHoursWorked());
}
// Implementasi dari method abstract di Employee interface
@Override
public boolean checkPromotionEligibility() {
if (calculatePay() > 1000.0) {
return true;
} else {
return false;
}
}
@Override
public boolean fired(){
if (this.calculatePay() < 300) {
return true;
}else{
return false;
}
}
@Override
public String toString() {
return "Store Details: " + getStoreDetails()+ "\nEmployee Name: " + getEmployeeName()
+ "\nBase Pay: $" + getBasePay() + "\nNumber of Hours worked: " + getNumberOfHoursWorked() + "hrs"
+ "\nPayment Rate per hour: $" + getHourlyRate() + "/hr"+"\nOvertime hours : "+ getOvertime()+" hour/s";
}
@Override
public double bonusHour(int hour){
int shiftHour = hour;
double bonuses = 0;
while (shiftHour >= 0) {
if (shiftHour >= 50) {
bonuses += 20;
shiftHour -=50;
}else{break;}
}
return bonuses;
}
}