/*****************************************************************
 * All the classes put together
 ****************************************************************/
/*****************************************************************
 * Superclass Employee 
 ****************************************************************/
class Employee
{
    private static String companyName  = "XYZ Inc.";    //class fields
    private static int    employeeCount;
    
    private String position;                            //instance fields
    private String lastname;
    private String firstname;
    private String sex;
    private 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( )                      
    {
        return (employeeCount);
    }
    static String getCompanyName( )                     
    {
        return (companyName);
    }
    String getFirstname( )        
    {
        return (firstname);
    }
    String getLastname( )        
    {
        return (lastname);
    }
    String getGender( )        
    {
        return (sex);
    }

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

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

    public String toString ( )                          //toString method
    {
        String data = "Position: " + position + 
                      "\t Name:  " + firstname +  " " + lastname + 
                      "\t Sex: "   + sex + "\t Age: " + age;
        return (data);
    }
}

/*****************************************************************
 * 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 ( )                              // override the toString()
    {
        String data = super.toString()  + "\n" +            //call the superclass toString()
                      "Salary: "        + salary + "\t " +
                      "Vacation Days: " + vacationDays + "\n";
        return (data);
    }
}

/*****************************************************************
 * Subclass PartTimer
 ****************************************************************/
class PartTimer extends Employee                        // extends Employee superclass
{    
    private static String  companyName = "Temp Co.";    // override the companyName
                                                        // from the Employee class

    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;  
    }

    String getFullname ( )                              // override the getFullname()
    {
        String sex = getGender();
        String salutation = (sex.equals("M")) ? "Mr." : "Ms.";

        String fullname  = salutation +" "+ getFirstname() +" "+ getLastname();
               fullname += "\t Part timer-Employee of "    + companyName;

        return (fullname);
    }

    public String toString ( )                          // override the toString()
    {
        String data = super.toString() + "\n" +         //call the superclass toString()
                      "Number Hours: " + numHours    + 
                      " Hourly Rate: " + hourlyRate  + "\n"; 
        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("Sec","Stevens","Bob","M",28,35000,10);

        PartTimer e4 = new PartTimer("NE","Williams","Bill","M",45,30,25);  
        PartTimer e5 = new PartTimer("NE","Johnson","Joan","F",32,25,22);  
 
        System.out.println(Employee.getCompanyName());      

        System.out.println(e1.getFullname());           //For FullTimers, 
        System.out.println(e2.getFullname());           //getFullName() of Employee 
        System.out.println(e3.getFullname());
        System.out.println(e4.getFullname());           //For PartTimers, getFullname() 
        System.out.println(e5.getFullname());           //getFullname() of PartTimer

        System.out.println();
           
        System.out.println(e1 + "\n" + e2 + "\n" + e3);     //It will choose the 
        System.out.println(e4 + "\n" + e5);                 //the correct toString()
   }
}