Java Reference
In-Depth Information
Display 7.3 The Derived Class HourlyEmployee (part 2 of 3)
43
public double getRate()
44
{
45
return wageRate;
46
}
47
public double getHours()
48
{
49
return hours;
50
}
51
/**
52
Returns the pay for the month.
53
*/
54
public double getPay()
55
{
56
return wageRate*hours;
57
}
58
/**
59
Precondition: hoursWorked is nonnegative.
60
*/
61
public void setHours( double hoursWorked)
62
{
63
if (hoursWorked >= 0)
64
hours = hoursWorked;
65
else
66
{
67
System.out.println("Fatal Error: Negative hours worked.");
68
System.exit(0);
69
}
70
}
71
/**
72
Precondition: newWageRate is nonnegative.
73
*/
74
public void setRate( double newWageRate)
75
{
76
if (newWageRate >= 0)
77
wageRate = newWageRate;
78
else
79
{
80
System.out.println("Fatal Error: Negative wage rate.");
81
System.exit(0);
82
}
83
}
Search WWH ::




Custom Search