Package homework3

Source Code of homework3.HourlyEmployee

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package homework3;

import org.omg.CORBA.DynAnyPackage.InvalidValue;

/**
*
* @author ASUS
*/
public class HourlyEmployee extends Employee {
   
// <editor-fold defaultstate="expanded" desc="Private Data Members">
   
    private Integer wage;
    private Integer hours;

// </editor-fold>
   
// <editor-fold defaultstate="expanded" desc="Constructors">
   
    public HourlyEmployee(String FirstName, String LastName, long NationalSN, int Wage, int Hours) throws InvalidValue
    {
        super(FirstName,LastName,NationalSN);
        setWage(Wage);
        setHours(Hours);
    }
   
// </editor-fold>
   
// <editor-fold defaultstate="expanded" desc="Getters and Setters">
   
    public final Integer getHours() {
        return hours;
    }

    public final void setHours(Integer hours) throws InvalidValue {
        if (hours>0)
            this.hours = hours;
        else
            throw new InvalidValue("Hours cannot be negative");
    }

    public final Integer getWage() {
        return wage;
    }

    public final void setWage(Integer wage) throws InvalidValue {
        if (wage>0)
            this.wage = wage;
        else
            throw new InvalidValue("Wage cannot be negative");
    }

// </editor-fold>
   
    public @Override Double earning()
    {
        return (double)(hours * wage);
    }
   
    public @Override String toString()
    {
        String Temp = "Hourly Employee "
                    + super.toString()
                    + "\nWage: " + wage.toString()
                    + "\nHours: " + hours.toString();
        return Temp;
    }
   
    public @Override Double getPaymentAmount()
    {
        return earning();
    }
   
}
TOP

Related Classes of homework3.HourlyEmployee

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.