-
Notifications
You must be signed in to change notification settings - Fork 0
/
HourlyEmployee.java
55 lines (46 loc) · 1.18 KB
/
HourlyEmployee.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
public class HourlyEmployee extends Employee
{
private int hoursWorked;
private double rateHourly;
public HourlyEmployee()
{
super();
hoursWorked = 0;
rateHourly = 0;
}
public HourlyEmployee(String fname, String lname, int hours, double rate)
{
super(fname, lname);
hoursWorked = hours;
rateHourly = rate;
}
public int getHoursWorked()
{
return hoursWorked;
}
public double getRateHourly()
{
return rateHourly;
}
public void setHoursWorked(int hours)
{
hoursWorked = hours;
}
public void setrateHourly(double rate)
{
rateHourly = rate;
}
public double calculateWeeklyPay()
{
if(hoursWorked <= 40)
return hoursWorked * rateHourly;
else
return (40 * rateHourly) + ((hoursWorked - 40) * rateHourly * 2);
}
public String toString()
{
return super.toString() + ", " + "Hours Worked: " + hoursWorked +
", Rate Per Hour: " + rateHourly + ", Weekly Pay: $" +
calculateWeeklyPay();
}
}