Class Employee

java.lang.Object
  |
  +--Employee

public class Employee
extends Object

An Employee contains information about an employee that would be important to a payroll application, such as wage and hours worked per week.

Version:
26 Aug 2003
Author:
Zach Tomaszewski

Constructor Summary
Employee(String name, int id)
          Constructor that assumes a $5.75 wage and 40 hours/week.
Employee(String name, int id, int hoursWorked, double payPerHour)
          Constructor.
 
Method Summary
 boolean equals(Employee otherEmployee)
          Returns true if two employees have the same name and ID and false otherwise.
 boolean equals(int otherID)
          Returns true if the given int is equal to this employee's ID; otherwise returns false.
 boolean equals(String otherName)
          Returns true if the given String is equal to this employee's name.
 int getHoursWorked()
          Returns the number of hours worked
 int getID()
          Returns this Employee's ID number
 String getName()
          Returns this Employee's name.
 double getPayPerHour()
          Returns this employee's hourly wage.
 double getWeeklyPay()
          Returns weekly pay, which is hours worked * pay per hour.
 void setHoursWorked(int newHoursWorked)
          Updates hours worked by this Employee.
 void setID(int newID)
          Updates this Employee's ID number.
 void setName(String newName)
          Updates this Employee's name.
 void setPayPerHour(double newPayPerHour)
          Updates this employee's hourly pay.
 String toString()
          Returns a String version of this Employee.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Employee

public Employee(String name,
                int id)
Constructor that assumes a $5.75 wage and 40 hours/week.

Employee

public Employee(String name,
                int id,
                int hoursWorked,
                double payPerHour)
Constructor.
Method Detail

getName

public String getName()
Returns this Employee's name.
Returns:
employee's name

setName

public void setName(String newName)
Updates this Employee's name.
Parameters:
newName - a String containing the employee's name

getID

public int getID()
Returns this Employee's ID number
Returns:
employee's id

setID

public void setID(int newID)
Updates this Employee's ID number. Does not ensure that the ID is unique among existing Employee's.
Parameters:
newID - an int to serve as the new ID for this employee

getHoursWorked

public int getHoursWorked()
Returns the number of hours worked
Returns:
number of hours this Employee has worked

setHoursWorked

public void setHoursWorked(int newHoursWorked)
Updates hours worked by this Employee. Sets hours worked equal to newHoursWorked.
Parameters:
newHoursWorked - a count of hours worked

getPayPerHour

public double getPayPerHour()
Returns this employee's hourly wage.
Returns:
the employee's current wage

setPayPerHour

public void setPayPerHour(double newPayPerHour)
Updates this employee's hourly pay. Sets the pay equal to the given newPayPerHour.
Parameters:
newPayPerHour - the new wage for this employee

getWeeklyPay

public double getWeeklyPay()
Returns weekly pay, which is hours worked * pay per hour. If the employee worked more than 40 hours, the overtime is paid at a rate of 120% of their normal pay per hour.
Returns:
the weekly pay received by this employee

equals

public boolean equals(Employee otherEmployee)
Returns true if two employees have the same name and ID and false otherwise. Other employee's data does not need to be identical between the two instances.
Parameters:
otherEmployee - employee to compare with this one
Returns:
whether these the two employees are equal

equals

public boolean equals(String otherName)
Returns true if the given String is equal to this employee's name.

equals

public boolean equals(int otherID)
Returns true if the given int is equal to this employee's ID; otherwise returns false.

toString

public String toString()
Returns a String version of this Employee.
Overrides:
toString in class Object