/** HourlyWorker - A class to represent workers paid on a salaried basis)
 *
 * @author - Nancy Harris and Jeremy Halterman
 * @version - V1 - 1.1
 * @date - 10-01-08
 */
 
 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 double hours;		// the hours that this worker last worked
	
	private double grossPay;    //a new field for holding the hourly pay
	
	/*new field homeDepartment*/
	private String homeDepartment;
	
	/** 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
	 */
	public HourlyWorker(String name, String SSN, int exempt,
			double rate, String dept)
	{
		this.name = name;
		this.SSN = SSN;
		this.exemptions = exempt;
		this.wage = rate;
		this.homeDepartment = dept;
	}
	
	/** 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 this.grossPay  The amount to pay this employee
	 */
	public double pay(double hours)
	{
		this.hours = hours;  // stores the hours worked
		
		//declares and initializes a local variable for holding the amount of OT
		double overtimePay = 0;
		//a constant that is 80 hours biweekly 
		final double reghours = 80;
		//a variable for multiplying the overtime hours by
		double payRate = 0;
		
        //figure regular pay for 80 hours, then figure for over 80 hours
		if(this.hours > reghours)
		{                             
            //establishes pay for 80 hour or under
			this.grossPay = reghours * this.wage;
			
			//states the overtime rate
			payRate = this.wage * 1.5;
			
			/*figures the overtime pay by subtracting 
			 * the 80 hour base from the actual hours*/
			overtimePay = (this.hours - reghours) * payRate;
			
			//add overtime into gross pay
			this.grossPay += overtimePay;
		}
		else                                //calculate gross pay
			{
			
			this.grossPay = this.hours * this.wage;
			}//end if-else   
		
		//return gross pay
		return this.grossPay;
	}//end hourly pay method
	
	/** toString produces a single line for each employee
	 *
	 *  format is Name\tSSN\texemptions\thours\trate\n
	 *
	 * @return The line representing the employee
	 */
	 public String toString()
	 {
	 	return "Employee: " + this.name + "\n"
	 	        +"SSN: " + this.SSN + "\n" +
	 	        "Department: " + this.homeDepartment + "\n" +
	 	        "Exemptions: " + this.exemptions + "\n"+
	 	        "Hours: " + this.hours +"\n" +
	 	        "Rate: " + this.wage + "\n" +
	 	        "Pay: " + this.grossPay;
	 }//end toString
}//end HourlyWorker Class