Source of WorkerWithIFace.java


  1: //WorkerWithIFace.java
  2: //This class implements the NameAndPayInterface.

  4: public class WorkerWithIFace
  5: implements NameAndPayInterface
  6: {
  7:     protected String nameOfWorker;
  8:     protected double hoursWorked;
  9:     protected double rateOfPay;


 12:     public WorkerWithIFace(String name)
 13:     {
 14:         nameOfWorker = name;
 15:     }

 17:     public void setHoursWorked(double hours)
 18:     {
 19:         hoursWorked = hours;
 20:     }

 22:     public void setRateOfPay(double rate)
 23:     {
 24:         rateOfPay = rate;
 25:     }


 28:     //Here is the implementation of the NameAndPayInterface interface:
 29:     public String getName()
 30:     {
 31:         return nameOfWorker;
 32:     }
 33:     
 34:     public double getGrossWage()
 35:     {
 36:         return hoursWorked * rateOfPay;
 37:     }
 38: }