/**************************************************************************
 * All classes together
 *************************************************************************/
/**************************************************************************
 * The Employee class
 * Printing the value of "this" reference
 *************************************************************************/
class Employee 
{
    static String companyName  =  "XYZ inc.";               //static fields
    static int    employeeCount;                            //belong to the class
    
    String position;                                        //instance fields
    String lastname;                                        //belong to each object
    String firstname;
    String sex;
    int    age;

    Employee(String title , String last, String first, String x, int old)     //constructor
    {
        position  = title;
        lastname  = last;
        firstname = first;
        sex       = x;
        age       = old;        
        employeeCount += 1; 
    }
    
    public String toString()                                        
    {                                                               
        System.out.printf("'this' reference is: %x \t", System.identityHashCode(this));     //print the value of "this"

        String data = "Company  "  + companyName +                               
                      "\t Name: "  + firstname +" "+ lastname + 
                      "\t Sex:  "  + sex + 
                      "\t Age:  "  + age;
        return (data);
    }
}                   

/**************************************************************************
 * The tester class
 *************************************************************************/
public class EmployeeTest
{
    public static void main (String[ ] args)
    { 
        Employee e1 = new Employee("Dir","Sultan","Sam","M",45);
        System.out.printf("e1 reference is:  %x \n", System.identityHashCode(e1) );
        System.out.println(e1.toString());                  
        System.out.println();
   
        Employee e2 = new Employee("Mgr","Smith","Mary","F",35);    
        System.out.printf("e2 reference is:  %x \n", System.identityHashCode(e2) );
        System.out.println(e2.toString());                  
        System.out.println();

        Employee e3 = new Employee("Sec","Stevens","Bob","M",28);
        System.out.printf("e3 reference is:  %x \n", System.identityHashCode(e3) );
        System.out.println(e3.toString());                                                
        System.out.println();
    }
}