/**
 * An employee with name, hours worked, and hourly pay rate.
 * 
 * @author (your name)
 * @version (date)
 */
public class Employee 
{
    // instance variables 
    private String name;
    private double hours, rate;
    private static final double TAX_RATE = 0.10;
    
    /**
     * Constructor for objects of class Employee
     * 
     * @param nameArg            the employee's name
     * @param hoursArg           how many hours worked
     * @param rateArg            hourly rate, in dollars
     */
    public Employee(String nameArg, double hoursArg, double rateArg)
    {
        // initialize instance variables
        this.name = nameArg;
        this.hours = hoursArg;
        this.rate = rateArg;
    }
    
    /**
     * valid: decide whether instance vars make sense.  The hours and rate
     * should be non-negative, i.e. at least 0.
     * 
     * @return     a boolean, true if things make sense; false otherwise.
     */
    public boolean valid ()
    {
        /*
        boolean result = false;
        if ((this.hours >= 0) && (this.rate >= 0))
            result = true;
        return result;
        */
       
        return ((this.hours >= 0) && (this.rate >= 0));
    }

    /**
     * printErrorMessage: what it sounds like.
     *
     * Precondition: Employee state has been determined to be invalid.
     * Postcondition: An error message is printed.
     */
    public void printErrorMessage ()
    {
        //if (! this.valid())
        System.out.println ("Error: hours and rate must be non-negative.");
    }

    /**
     * computeNetPay: a service method that computes net pay 
     * by invoking helper methods computeGrossPay and computeTax.
     * Precondition: Employee state has been determined to be valid.
     * Postcondition: The net pay is computed and returned.
     * 
     * @return     a double, the net pay, after taxes.
     */
    public double computeNetPay ()
    {
        double netPay, grossPay, tax;
        
        grossPay = this.computeGrossPay ();

        tax = this.computeTax (grossPay);
        
        netPay = grossPay - tax;
        
        return netPay;
    }

    /**
     * computeGrossPay: what it sounds like.
     * 
     * @return the gross pay.
     */
    private double computeGrossPay ()
    {
        double grossPay;
        grossPay = this.hours * this.rate;
        return grossPay;
    }
    
    /**
     * computeTax: a helper method that computes the tax
     * which is the gross pay multiplied by the tax rate. 
     * 
     * @param      a double, the gross pay.
     * @return     a double, the tax.
     */
    private double computeTax (double gross)
    {
        double tax;
        tax = gross * TAX_RATE;
        return tax;
    } 

} 





