/************************************************************************************************
 * 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 xEmployeeTest
{
    /**
     * main method to test the classes
     */

    public static void main (String[ ] args)
    {        
    /**
     * All employees will be created using variables type Employee,
     * but the objects created will be either FullTimer or PartTimer
     */ 

        Employee[ ] emp = new Employee[10];     //Create an array of Employees

        emp[0] = new FullTimer("Dir","Sultan","Sam","M",48,78000,12);   //assign a FullTimer   
        emp[1] = new FullTimer("Mgr","Smith","Mary","F",35,62400,12);   //to an Employee reference 
        emp[2] = new FullTimer("Sec","Stevens","Bob","M",28,44200,10);

        emp[3] = new PartTimer("NE","Williams","Bill","M",45,30,25);  
        emp[4] = new PartTimer("NE","Johnson","Joan","F",32,25,22);  
 
        System.out.println(emp[0].getFullname());               //Even though all employees  
        System.out.println(emp[0].getWeekPay());                //created are members of
                                                                //the Employee class,
        System.out.println(emp[1].getFullname());               //   
        System.out.println(emp[1].getWeekPay());                //when calling 
                                                                //getFullName() or getWeekPay() 
        System.out.println(emp[2].getFullname());               //Java will NOT call 
        System.out.println(emp[2].getWeekPay());                //the Employee class                         
                                                                //getFullName() or getWeekPay()
        System.out.println(emp[3].getFullname());               //   
        System.out.println(emp[3].getWeekPay());                //but rather will choose the    
                                                                //correct subclass method 
        System.out.println(emp[4].getFullname());               //based on the subclass 
        System.out.println(emp[4].getWeekPay());                //object that's being referenced         

        System.out.println("\n ---Better yet, Using a Loop ---");

        for (int i = 0; i < emp.length; i++)
        {
            if (emp[i] != null)         //check for null slots
            {
                System.out.println(emp[i].getFullname());
                System.out.println(emp[i].getWeekPay());
            }
        }
    }
}