-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSalariedEmployee.java
60 lines (52 loc) · 1.41 KB
/
SalariedEmployee.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
public class SalariedEmployee extends Employee
{
private double weeklySalary;
private boolean hasBonus;
public SalariedEmployee()
{
super();
weeklySalary = 0;
hasBonus = false;
}
public SalariedEmployee(String fname, String lname,
double salary, boolean bonus)
{
super(fname, lname);
weeklySalary = salary;
hasBonus = bonus;
}
public double getWeeklySalary()
{
return weeklySalary;
}
public void setWeeklySalary(double salary)
{
weeklySalary = salary;
}
public boolean isBonus()
{
return hasBonus;
}
public void setBonus(boolean bonus)
{
hasBonus = bonus;
}
public double calculateWeeklyPay()
{
if(hasBonus)
return weeklySalary + weeklySalary * 0.10;
else
return weeklySalary;
}
public String toString()
{
if(hasBonus)
return super.toString() + ", " + "Weekly Salary: " +
weeklySalary + ", Bonus: " + (weeklySalary * 0.10) +
", Weekly Pay: $" + calculateWeeklyPay();
else
return super.toString() + ", " + "Weekly Salary: " +
weeklySalary + ", Bonus: 0" + ", Weekly Pay: $" +
calculateWeeklyPay();
}
}