//*******************************************************************
//
//   Firm.java          In Text          Application
//
//   Authors:  Lewis and Loftus
//
//   Classes:  Firm
//             Employee
//             Executive
//
//*******************************************************************


//-------------------------------------------------------------------
//
//  Class Firm contains the driver of a program that manages a set
//  of employees.
//
//  Methods:
//
//     public static void main (String[] args)
//
//-------------------------------------------------------------------

class Firm {

   //===========================================================
   //  Creates several employees, including an executive, and
   //  pays them.
   //===========================================================
   public static void main (String[] args) {

      Executive sam = new Executive ("Sam", "123 Main Line",
         "555-0469", "123-45-6789", 1923.07);
      Employee carla = new Employee ("Carla", "456 Off Line",
         "555-0101", "987-65-4321", 846.15);
      Employee woody = new Employee ("Woody", "789 Off Rocker",
         "555-0000", "010-20-3040", 769.23);

      woody.print();
      System.out.println ("Paid: " + woody.pay());
      System.out.println();

      carla.print();
      System.out.println ("Paid: " + carla.pay());
      System.out.println();

      sam.print();
      sam.award_bonus (2000);
      System.out.println ("Paid: " + sam.pay());
      System.out.println();

   }  // method main

}  // class Firm

//-------------------------------------------------------------------
//
//  Class Employee represents one general employee of a company.
//
//  Constructors:
//
//     public Employee (String emp_name, String emp_address,
//                      String emp_phone, String emp_ssnumber,
//                      double emp_rate)
//
//  Methods:
//
//     public double pay ()
//     public void print ()
//
//-------------------------------------------------------------------

class Employee {

   protected String name;
   protected String address;
   protected String phone_number;
   protected String social_security_number;
   protected double pay_rate;

   //===========================================================
   //  Sets up an employee with the specified information.
   //===========================================================
   public Employee (String emp_name, String emp_address,
                    String emp_phone, String emp_ssnumber,
                    double emp_rate) {

      name = emp_name;
      address = emp_address;
      phone_number = emp_phone;
      social_security_number = emp_ssnumber;
      pay_rate = emp_rate;

   }  // constructor Employee

   //===========================================================
   //  Returns the pay rate for this employee.
   //===========================================================
   public double pay () {

      return pay_rate;

   }  // method pay

   //===========================================================
   //  Prints the basic information about an employee.
   //===========================================================
   public void print () {

      System.out.println (name + "   " + social_security_number);
      System.out.println (address);
      System.out.println (phone_number);

   }  // method print

}  // class Employee

//-------------------------------------------------------------------
//
//  Class Executive represents one executive, which is an employee
//  that can possibly earn a bonus.
//
//  Constructors:
//
//     public Executive (String exec_name, String exec_address,
//                       String exec_phone, String exec_ssnumber,
//                       double exec_rate)
//
//  Methods:
//
//     public void award_bonus (double exec_bonus)
//     public double pay ()
//
//-------------------------------------------------------------------

class Executive extends Employee {

   private double bonus;

   //===========================================================
   //  Sets up an executive with the specified information.
   //===========================================================
   public Executive (String exec_name, String exec_address,
                     String exec_phone, String exec_ssnumber,
                     double exec_rate) {

      super (exec_name, exec_address, exec_phone, exec_ssnumber,
             exec_rate);

      bonus = 0;  // bonus yet to be awarded

   }  // constructor Executive

   //===========================================================
   //  Awards the specified bonus to this Executive.
   //===========================================================
   public void award_bonus (double exec_bonus) {

      bonus = exec_bonus;

   }  // method award_bonus

   //===========================================================
   //  Computes and returns the pay for an executive, which is
   //  the regular salary plus a one-time bonue.  Overrides
   //  the pay method of the Employee class.
   //===========================================================
   public double pay () {

      double paycheck = super.pay() + bonus;
      bonus = 0;
      return paycheck;

   }  // method pay

}  // class Executive


