/*****************************************************************
 * All the classes put together
 ****************************************************************/
/*****************************************************************
 * Superclass Employee
 ****************************************************************/
class Employee
{
    static String companyName  = "XYZ inc.";            //class fields
    static int    employeeCount;
    
    String position;                                    //instance fields
    String lastname;
    String firstname;
    String sex;
    int    age;

    Employee(String title)                              //first constructor
    {
        position       = title;
        employeeCount += 1;         
    }

    Employee(String title, String last, String first, String x, int old)   
    {
        this(title);                                    //call first constructor
                                                        //and pass it title
        lastname  = last;
        firstname = first;  
        sex       = x;
        age       = old;
    }

    static int getEmployeeCount()                      //class method
    {
        return (employeeCount);
    }

    String getFullname()                               //instance method
    {
        String salutation = (sex.equals("M")) ? "Mr." : "Ms.";

        String fullname   = salutation +" "+ firstname +" "+ lastname;
        return (fullname);
    }
}

/*****************************************************************
 * Subclass FullTimer
 ****************************************************************/
class FullTimer extends Employee                    // extends Employee superclass
{
    private static boolean healthPlan = true;       // add class variables
    
    private int salary;                             // add instance variables
    private int vacationDays;

    FullTimer(String title, String last, String first, String x, int old,
              int sal, int vac)   
    {
        super(title, last, first, x, old);           // call superclass constructor
                                                     // pass it title,last,first,sex,age
        salary       = sal;
        vacationDays = vac;  
    }

    public String toString()                        //toString instance method
    {
        String name = getFullname();				//call getFullname() method
        String data = "Position: " + position + 
                      "\t Name:  " + name + 
                      "\t Sex: "   + sex  + "\t Age: " + age +
                      "\t Salary: "+ salary;
        return (data);
    }
}

/*****************************************************************
 * Subclass PartTimer
 ****************************************************************/
class PartTimer extends Employee                    // extends Employee superclass
{
    private static boolean healthPlan = false;      // add class variables
    
    private int numHours;                           // add instance variables
    private int hourlyRate;

    PartTimer(String title, String last, String first, String x, int old,
              int hours, int rate)   
    {
        super(title, last, first, x, old);           // call superclass constructor
                                                     // pass it title,last,first,sex,age
        numHours   = hours;
        hourlyRate = rate;  
    }

    public String toString()                        //toString instance method
    {
        String name = getFullname();				//call getFullname() method
        String data = "Position: " + position + 
                      "\t Name:  " + name + 
                      "\t Sex: "   + sex  + "\t Age: "  + age +
                      "\t Hours: " + numHours +  " @ rate: " + hourlyRate;
        return (data);
    }
}


/*****************************************************************
 * The tester class
 ****************************************************************/
public class xEmployeeTest
{
    public static void main (String[ ] args)
    {        
        FullTimer e1 = new FullTimer("Dir","Sultan","Sam","M",48,45000,12);  
        FullTimer e2 = new FullTimer("Mgr","Smith","Mary","F",35,40000,12);  
        FullTimer e3 = new FullTimer("Asst","Stevens","Bob","M",28,35000,10);

        PartTimer e4 = new PartTimer("NE","Willis","Bill","M",45,30,25);  
        PartTimer e5 = new PartTimer("NE","Grant","Joan","F",32,25,22);  
 
        System.out.println(Employee.companyName);       //access it thru Employee
        System.out.println(FullTimer.companyName);      //or FullTimer or PartTimer
        System.out.println(PartTimer.companyName);      //(companyName is inherited)

        System.out.println(e1.getFullname());           //getFullname() method
        System.out.println(e2.getFullname());           //is inherited from 
        System.out.println(e3.getFullname());           //the Employee class
        System.out.println(e4.getFullname());           //to Fulltimer class,
        System.out.println(e5.getFullname());           //and PartTimer class

        int count;

        count = Employee.getEmployeeCount();                //You can call this method
        System.out.println("Number employees: " + count);   //on the Employee class

        count = FullTimer.getEmployeeCount();               //or you can also call it
        System.out.println("Number employees: " + count);   //on the FullTimer class
        count = PartTimer.getEmployeeCount();               //or the PartTimer class    
        System.out.println("Number employees: " + count);   //(method is inherited)
       
        System.out.println(e1 + "\n" + e2 + "\n" + e3);     //call the toString()  
        System.out.println(e4 + "\n" + e5);                 //inherited from Employee
   }
}