SalariedEmployee.java.html

  1  /**
  2     A salaried employee is paid the same amount independent of the hours worked.
  3  */
  4  public class SalariedEmployee extends Employee
  5  {
  6     private double annualSalary;
  7  
  8     /**
  9        Constructs a salaried employee with a given name and annual salary.
 10        @param name the name of this employee
 11        @param salary the annual salary
 12      */
 13     public SalariedEmployee(String name, double salary)
 14     {
 15        setName(name);
 16        annualSalary = salary;
 17     }
 18  
 19     public double weeklyPay(int hoursWorked) 
 20     {
 21        final int WEEKS_PER_YEAR = 52;
 22        return annualSalary / WEEKS_PER_YEAR;
 23     }
 24  }