Source of Worker.java


  1: //Worker.java
  2: //This class definition "encapsulates" our idea of a worker by providing
  3: //definitions for the "attributes" and "behavior" of a worker.

  5: public class Worker
  6: {
  7:     protected String nameOfWorker;
  8:     protected float hoursWorked;
  9:     protected float rateOfPay;


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

 17:     public String getName()
 18:     {
 19:         return nameOfWorker;
 20:     }

 22:     public void setHoursWorked(float hours)
 23:     {
 24:         hoursWorked = hours;
 25:     }

 27:     public void setRateOfPay(float rate)
 28:     {
 29:         rateOfPay = rate;
 30:     }

 32:     public float getGrossWage()
 33:     {
 34:         return hoursWorked * rateOfPay;
 35:     }
 36: }