Class HourlyEmployee

  • All Implemented Interfaces:
    Employee
    Direct Known Subclasses:
    PartTimeEmployee

    public class HourlyEmployee
    extends java.lang.Object
    implements Employee
    A representation of an hourly employee, which will keep track of their hours in order to be able to calcuate their current expected pay
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int IDNum
      Their Employee ID number
      java.lang.String name
      The name by which the person will be represented
      java.lang.String title
      Their job title or description
    • Constructor Summary

      Constructors 
      Constructor Description
      HourlyEmployee​(java.lang.String name, java.lang.String title, int id, double wage)
      Create an Hourly Employee with the following infomation and setting the shift to "day"
      HourlyEmployee​(java.lang.String name, java.lang.String title, int id, double wage, java.lang.String shift)
      Create an Hourly Employee with the following infomation
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHours​(double hours)
      Add the appropriate hours to their time card
      double pay​(double taxRate)
      Process the hours that they have worked, returning the pay amount ((Hours worked * rate) * (1 - tax rate)) and resetting the hours to zero
      void setShift​(java.lang.String shift)
      Set their work shift
      java.lang.String toString()
      How to display the employee
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        public java.lang.String name
        The name by which the person will be represented
      • title

        public java.lang.String title
        Their job title or description
      • IDNum

        public int IDNum
        Their Employee ID number
    • Constructor Detail

      • HourlyEmployee

        public HourlyEmployee​(java.lang.String name,
                              java.lang.String title,
                              int id,
                              double wage)
        Create an Hourly Employee with the following infomation and setting the shift to "day"
        Parameters:
        name - Their name representing the person
        title - Their title or job description
        id - Their employee id number
        wage - Their starting hourly wage
      • HourlyEmployee

        public HourlyEmployee​(java.lang.String name,
                              java.lang.String title,
                              int id,
                              double wage,
                              java.lang.String shift)
        Create an Hourly Employee with the following infomation
        Parameters:
        name - Their name representing the person
        title - Their title or job description
        id - Their employee id number
        wage - Their starting hourly wage
        shift - What shift will they be working
    • Method Detail

      • toString

        public java.lang.String toString()
        How to display the employee
        Specified by:
        toString in interface Employee
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation of an employee
      • pay

        public double pay​(double taxRate)
        Process the hours that they have worked, returning the pay amount ((Hours worked * rate) * (1 - tax rate)) and resetting the hours to zero
        Specified by:
        pay in interface Employee
        Parameters:
        taxRate - The current tax rate for the employee
        Returns:
        the pay for this pay period, (Hours worked * rate) * (1 - tax rate)
      • addHours

        public void addHours​(double hours)
        Add the appropriate hours to their time card
        Parameters:
        hours - hours to add to their total
      • setShift

        public void setShift​(java.lang.String shift)
        Set their work shift
        Parameters:
        shift - the shift they are going to be working