/*
 *  File: Employee.java
 *  Name: cpsc115 
 
    This example illustrates the use of inheritance and polymorphism in
    calculating an employee's salary.  There are two types of Employees,
    HourlyEmployees and SalaryEmployees.  Both types have the name, id, 
    and jobTitle attributes in common. So these are defined in the superclass.
    HourlyEmployees and SalaryEmployees have different ways of calculating 
    their pay. Therefore, the calculatePay() method is defined as a trivial
    stub method in the Employee superclass and then overridden in the subclasses.
    Note how the toString() method uses the calculatePay() method.  When
    toString() is called on an object, Java needs to check what kind of
    Employee object it is in order to call the right version of calculatePay(),
    either the one for HourlyEmployee or SalaryEmployee. 

 */
public class Employee {

    private String name;
    private int id;
    private String jobTitle;

    public Employee(String name, int id, String title) {
	this.name = name;
	this.id = id;
	this.jobTitle = title;
    }

    public String getName() {
	return name;
    }
    public void setName(String name) {
	this.name = name;
    }

    public int getId() {
	return id;
    }
    public void setId(int id) {
	this.id = id;
    }

    public String getJobTitle() {
	return jobTitle;
    }
    public void setJobTitle(String title) {
	this.jobTitle = title;
    }

    /**
     *  This method should be overridden in the subclass to 
     *  apply the appropriate pay calculations for different
     *  types of Employees.
     */
    public double calculatePay() {
	return 0;
    }

    public String toString() {
	return "Pay to the order of " + name + ", " + jobTitle + ", $" + calculatePay();
    }

    public static void main(String args[]) {
	Employee e1 = new HourlyEmployee("Joe", 1001, "Lab Technician", 40, 15.75);
	Employee e2 = new SalaryEmployee("Mary", 1002, "Professor", 1000.75);
	System.out.println(e1);
	System.out.println(e2);
	
    }

}