Class HourlySalaryCheck

java.lang.Object
  extended by PayrollCheck
      extended by HourlySalaryCheck

public class HourlySalaryCheck
extends PayrollCheck

HourlySalaryCheck class definition for employees who are payed an hourly rate. The field hoursWorked is multiplied by payRate to calculate gross pay.

Version:
Copyright (c) 2001
Author:
Carl B. Struck

Field Summary
(package private)  java.text.DecimalFormat dollarsCents
           
(package private)  java.text.DecimalFormat twoDecimals
           
 
Constructor Summary
HourlySalaryCheck()
          No argument constructor sets fields hoursWorked and payRate to default values zero (0).
HourlySalaryCheck(int checkNumber, int employeeID, double hoursWorked, double payRate)
          The constructor sets initial values for fields hoursWorked and payRate.
 
Method Summary
 double getGrossPay()
          Calculates and returns weekly gross pay.
 double getHoursWorked()
          Returns current value of the hoursWorked field.
 double getPayRate()
          Returns current value of the payRate field.
 java.lang.String printLine()
          Returns detail line information for hoursWorked and payRate fields, and calculated gross pay for a columnar report.
 void setHourlySalaryCheck(double hoursWorked, double payRate)
          Method takes parameters for the fields hoursWorked and payRate and passes them to their respective set methods.
 void setHoursWorked(double hoursWorked)
          Sets the value for the hoursWorked field which must be between 0.25 and 168.0.
 void setPayRate(double payRate)
          Sets the value for the payRate field which must be between 7.25 and 75.00.
 java.lang.String toString()
          Returns formatted hoursWorked and payRate fields, and calculated gross pay including text labels.
 
Methods inherited from class PayrollCheck
getCheckNumber, getEmployeeID, printHeading, setCheckNumber, setEmployeeID, setPayrollCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dollarsCents

java.text.DecimalFormat dollarsCents

twoDecimals

java.text.DecimalFormat twoDecimals
Constructor Detail

HourlySalaryCheck

public HourlySalaryCheck()
No argument constructor sets fields hoursWorked and payRate to default values zero (0). Implicit call to superclass PayrollCheck sets fields employeeID and checkNumber to default values zero (0).


HourlySalaryCheck

public HourlySalaryCheck(int checkNumber,
                         int employeeID,
                         double hoursWorked,
                         double payRate)
The constructor sets initial values for fields hoursWorked and payRate. Explicit call to superclass PayrollCheck sets initial values for fields employeeID and checkNumber.

Parameters:
checkNumber - Number of payroll check from superclass Payroll.
employeeID - Employee's identification number from superclass Payroll.
hoursWorked - Number of hours worked for the week.
payRate - Employee's hourly pay rate.
Method Detail

getGrossPay

public double getGrossPay()
Calculates and returns weekly gross pay. For employees who work 40 hours or less, field hoursWorked is multiplied by payRate to calculate gross pay; for employees who work more than 40 hours, gross pay calculated with time and a half for overtime.

Returns:
Employee's weekly gross pay.

getHoursWorked

public double getHoursWorked()
Returns current value of the hoursWorked field.

Returns:
Number of hours worked for the week.

getPayRate

public double getPayRate()
Returns current value of the payRate field.

Returns:
Employee's hourly pay rate.

printLine

public java.lang.String printLine()
Returns detail line information for hoursWorked and payRate fields, and calculated gross pay for a columnar report. Preceded by checkNumber and employeeID fields from call to printLine() method of superclass PayrollCheck.

Overrides:
printLine in class PayrollCheck
Returns:
Hours worked, pay rate and gross pay for an hourly salary check as part of a detail line as type String.

setHourlySalaryCheck

public void setHourlySalaryCheck(double hoursWorked,
                                 double payRate)
Method takes parameters for the fields hoursWorked and payRate and passes them to their respective set methods.

Parameters:
hoursWorked - Number of hours worked for the week.
payRate - Employee's hourly pay rate.

setHoursWorked

public void setHoursWorked(double hoursWorked)
Sets the value for the hoursWorked field which must be between 0.25 and 168.0. A value of zero (0) indicates that hoursWorked field is empty.

Parameters:
hoursWorked - Number of hours worked for the week.

setPayRate

public void setPayRate(double payRate)
Sets the value for the payRate field which must be between 7.25 and 75.00. A value of zero (0) indicates that payRate field is empty.

Parameters:
payRate - Employee's hourly pay rate.

toString

public java.lang.String toString()
Returns formatted hoursWorked and payRate fields, and calculated gross pay including text labels. Preceded by checkNumber and employeeID fields from call to toString() method of superclass PayrollCheck.

Overrides:
toString in class PayrollCheck
Returns:
Formatted hours worked, pay rate and gross pay for an hourly salary check as type String.