/**************************************************************************
 * All classes together
 *************************************************************************/
/**************************************************************************
 * The Employee class
 * Added multiple constructors 
 * Getters & Setters use Employee. and this. references
 *************************************************************************/
class Employee
{
    private static String companyName  = "XYZ inc.";     //static fields
    private static int    employeeCount;
    
    private String position  = "";                       //instance fields
    private String lastname  = "";
    private String firstname = "";
    private String sex;
    private int    age;


    //Creating multiple constructors

    Employee(String title)                              //first constructor
    {
        position       = title;
        employeeCount += 1;         
    }

//  Employee(String title, String last, String first, String x, int old)   
//  {
//      position  = title;                              //second constructor
//      lastname  = last;                             
//      firstname = first;                              //you can build it
//      sex       = x;                                  //like this, or like
//      age       = old;                                //the one below
//      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 String getCompanyName( )             
    {
        return (Employee.companyName);                  //"Employee" to indicate static field
    }
    static int getEmployeeCount( )              
    {
        return (Employee.employeeCount);
    }

    String getPosition( )                       
    {
        return (this.position);                         //"this" to indicate instance field
    }
    String getLastname( )                 
    {
        return (this.lastname);
    }
    String getFirstname( )                 
    {
        return (this.firstname);
    }
    String getGender( )                    
    {
        return (this.sex);
    }
    int getAge( )                          
    {
        return (this.age);
    }

    static void setCompanyName(String companyName)      
    {
        Employee.companyName = companyName;             //"Employee" to indicate static field
    }

    void  setPosition(String position)                  
    {
        this.position = position;                       //"this" to indicate instance field
    }
    void  setLastname(String lastname)         
    {
        this.lastname = lastname;
    }
    void  setFirstname(String firstname)       
    {
        this.firstname = firstname;
    }
    void  setGender(String sex)          
    {
        this.sex = sex;
    }
    void  setAge(int age)                 
    {
        this.age = age;
    }

    String getFullname (String sal)                 
    {
        String fullname  = sal + " " + this.firstname + " " + this.lastname;
        return (fullname);
    }

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


/**************************************************************************
 * The Employee Tester class
 * Calling the multiple constructors 
 *************************************************************************/
public class EmployeeTest
{
    public static void main (String[ ] args)
    {        
        System.out.println("Company name: "     + Employee.getCompanyName() );
        System.out.println("Number employees: " + Employee.getEmployeeCount() );

        Employee e1 = new Employee("Dir","Sultan","Sam","M",48);    //calling the large constructor
        Employee e2 = new Employee("Mgr","Smith","Mary","F",35);    
        Employee e3 = new Employee("Sec","Stevens","Bob","M",28);

        Employee chief = new Employee("Pres");                      //calling the small constructor
        Employee vp    = new Employee("VP");
        
        String name1 = e1.getFullname("Mr.");                       
        System.out.println(name1);
        String name2 = e2.getFullname("Ms."); 
        System.out.println(name2);
        String name3 = e3.getFullname("Mr."); 
        System.out.println(name3);
        String name4 = chief.getFullname("Mr. President"); 
        System.out.println(name4);
        String name5 = chief.getFullname("Mr. Vice president"); 
        System.out.println(name5);

        System.out.println("Number employees: " + Employee.getEmployeeCount() );
        System.out.println();
        
        System.out.println(e1.toString() );            //call the toString() method
        System.out.println(e2);                        //no need to say toString()
        System.out.println(e3);
        System.out.println(chief + "\n" + vp);         //you can concatenate them
    }
}