import orgChart.*;

/**
 * Test the Employee and Hierarchy classes that are part of package pkg1 
 */

public class HierarchyTest
{
    /**
     * main method to test the class
     */

    public static void main (String[ ] args)
    {        

        // Instantiate employee objects

        Employee pres = new Employee("Pres","Bush","George","M",54);  //create
        Employee vp   = new Employee("VP","Flanagan","Liz","F",52);   //objects
        Employee dir  = new Employee("Dir","Sultan","Sam","M",49);  
        Employee mgr  = new Employee("Mgr","Smith","Mary","F",35);  
        Employee sec  = new Employee("Sec","Stevens","Bob","M",28);

        System.out.println(pres);                         //call toString( )
        System.out.println(vp);                           //of Employee object
        System.out.println(dir);
        System.out.println(mgr);
        System.out.println(sec);
        System.out.println();

        // Build the org chart hierarchy
        // I forced postion number 2 & 3 to create a copy of the employee passed
        // rather than to simply reference the employee passed. 
        // (see difference between 1st & 2nd constructor in the Hierarchy class)
        
        Hierarchy level1 = new Hierarchy(pres, vp,  "Jan 2005");
        Hierarchy level2 = new Hierarchy(vp,   dir, "Feb 2005", "copy");
        Hierarchy level3 = new Hierarchy(dir,  mgr, "Mar 2005", "copy");
        Hierarchy level4 = new Hierarchy(mgr,  sec, "Apr 2005");
        Hierarchy level5 = new Hierarchy(sec,  null, "");
        
        System.out.println(level1);                          //call toString( )
        System.out.println(level2);                          //of Hierarchy object
        System.out.println(level3);
        System.out.println(level4);
        System.out.println(level5);
        System.out.println();
        
        pres.setLastname("Carlin");                         //change pres lastname
        dir.setLastname("Elliot");                          //change dir lastname

        System.out.println(pres);                           //call toString( )
        System.out.println(dir);                            //of Employee object
        System.out.println();
        
    //You will notice that in the reprint of the Hierarchy 
    //the name of the president was changed from George Bush to George Carlin, 
    //but the name of the director did not change from Sam Sultan.  Why?

        System.out.println(level1);                          //reprint Hierarchy
        System.out.println(level2);
        System.out.println(level3);
        System.out.println(level4);
        System.out.println(level5);
    }
}