/**********************************************************************************************
 * Test both the FullTImer and PartTimer classes
 * with override methods as polymorphism
 *
 * For polymorhism to work:
 *   Define a method in the superclass.  Example. getWeekPay( )  
 *   Override that method in both subclasses.  
 *   Create objects from those 2 subclasses, and assign them to variables of the superclass
 *   Call the method on those objects, Java will automatically call the correct getWeekPay( ) 
 ***********************************************************************************************/

public class xEmployeeTest2
{
    /**
     * main method to test the classes
     */

    public static void main (String[ ] args)
    {        
        FullTimer[ ] empF = new FullTimer[10];      //Create an array of Full Time Employees
        PartTimer[ ] empP = new PartTimer[10];      //Create an array of Part Time Employees

        empF[0] = new FullTimer("Dir","Sultan","Sam","M",48,78000,12);  
        empF[1] = new FullTimer("Mgr","Smith","Mary","F",35,62400,12);  
        empF[2] = new FullTimer("Sec","Stevens","Bob","M",28,44200,10);

        empP[0] = new PartTimer("NE","Williams","Bill","M",45,30,25);  
        empP[1] = new PartTimer("NE","Johnson","Joan","F",32,25,22);  
 
        System.out.println("--Printing both full and part time employees--");

        for (int i = 0; i < empF.length; i++)
        {
            Employee e = empF[i];               //assign FullTimer to Employee reference 
            printIt(e);
        }

        for (int i = 0; i < empP.length; i++)
            printIt(empP[i]);                   //send a PartTimer object                     
    }

    static void printIt(Employee e)                         //receive an Employee object
    {
        if (e != null)                                      //check for null elements
        {
            System.out.println(e.getFullname());            
            System.out.println(e.getWeekPay());             //this is a polymorphic 
        }
    }
}