/** HourlyWorker - A class to represent workers paid on a salaried basis)
 *
 * @author - Nancy Harris and Mark Koskinen
 * @version - V1 - October 1, 2008
 */
 
 public class HourlyWorker
 {
 	// declare the instance variables of the class
	
	private String name; 		// the name of the worker
	private String SSN;  		// the SSN of the worker
	private int exemptions;		// the number of tax exemptions for this worker
	private double wage; 		// the hourly rate for this hourly worker
	private String homeDepartment;  // the name of the department
	
	private double hours;		// the hours that this worker last worked
	
	/** explicit value constructor
	 * 
	 * @param name 	The name of the worker
	 * @param SSN  	The SSN of the worker
	 * @param exempt	The number of payroll exemptions
	 * @param rate 	The hourly rate for this employee
	 * @param homeDepartment the name of the department
	 */
	public HourlyWorker(String name, String SSN, int exempt, double rate, String homeDepartment)
	{
		this.name = name;
		this.SSN = SSN;
		this.exemptions = exempt;
		this.wage = rate;
		this.homeDepartment = homeDepartment;
	}
	
	/** pay produces the pay amount for this employee
	 *  pay the rate * hours.  (we are disregarding overtime at this time)
	 *
	 * @param hours The number of hours for this hourly worker
	 *
	 * @return The amount to pay this employee
	 */
	public double pay(double hours)
	{
		double result = 0;  // create a double variable to return
		this.hours = hours;
		// if less than 80 hours return the pay without any added overtime
		if(hours<=80) result = this.hours * this.wage;
		// if more than 80 hours return the 80 hour pay plus
		// add 50% more for each hour after
		if (hours>80) 
			{
			result = 80 * wage;   // start with standard 80 hour pay
			double hoursOver = (hours - 80); // create variable for hours over 80
			// multiply hours over 80 by wage times 50%
			hoursOver = hoursOver * wage * 1.5;
			result += hoursOver;
			}
		return result;
	}
	
	/** toString produces a single line for each employee
	 *
	 *  format is Name\tSSN\thomeDepartment\texemptions\thours\trate\n
	 *
	 * @return The line representing the employee
	 */
	 public String toString()
	 {
	 	return (name+"\t"+SSN+"\t"+homeDepartment+"\t"+exemptions+"\t"+hours+"\t"+wage+"\n");
	 }
}
