/**************************************************************************
 * The Employee Tester class
 * Adding an array of employees
 * Using the copy constructor to copy employee 
 * Using the clone() method to copy employee  
 *************************************************************************/
public class EmployeeTest
{
    public static void main (String[ ] args)
    {        
        Employee[] emp = new Employee[5];

        emp[0]  = new Employee("Prof","Sultan","Sam","M",44);  		//instantiate
        emp[1]  = new Employee("Dir","Burns","Barbara","F",48);  	//objects
        emp[2]  = new Employee("Mgr","Smith","Mary","F",35);  	

        System.out.println("The original employees: \n");

        System.out.println("Emp-0: " + emp[0]);
        System.out.println("Emp-1: " + emp[1]);
        System.out.println("Emp-2: " + emp[2]);
        System.out.println();
       

//----- Using a copy constructor -----------------------------------------------------------

        System.out.println("CREATING one object from another, using a COPY CONSTRUCTOR: \n");

        emp[3] = new Employee(emp[1]);             			//creating an object from another
        
        System.out.println("Emp-1: " + emp[1]);				//emp1 and emp3 should be identical
        System.out.println("Emp-3: " + emp[3]);                   
        System.out.println();

        System.out.println("Changing the title of emp3: \n");

        emp[3].setPosition("Pres");

        System.out.println("Emp-1: " + emp[1]);				
        System.out.println("Emp-3: " + emp[3]);                   
        System.out.println();
       

//----- Using the clone method ------------------------------------------------------------

        System.out.println();
        System.out.println("CLONNING one employee from another, using a CLONE METHOD: \n");

        emp[4] = emp[2].clone();                   			//cloning one employee from another

        System.out.println("Emp-2: " + emp[2]);        		//emp2 and emp4 should be identical
        System.out.println("Emp-4: " + emp[4]);                   
        System.out.println();

        System.out.println("Changing the title of emp4: \n");

        emp[4].setPosition("VP");

        System.out.println("Emp-2: " + emp[2]);
        System.out.println("Emp-4: " + emp[4]);                   
        System.out.println();

		System.out.println("Reprinting all employees: \n");

        for (int i=0; i<emp.length; i++)
            System.out.println("Emp-" + i + " " + emp[i]);                   
   }
}