/****************************************************************************
 * Employee class (to test access of fields/methods within the same class)
 ***************************************************************************/
public class Employee
{
    static String companyName  = "XYZ inc.";            //static fields
    static int    employeeCount;
    
    String lastname;                                    //instance fields
    String firstname;

    Employee(String first, String last)                 //constructor
    {
        firstname = first;
        lastname  = last;
        employeeCount++;
    }
    
    static int getEmployeeCount( )                                      //static method
    {
        return (employeeCount);
    }

    String getFullname(String sal)                                      //instance method
    {
        return(sal + " " + firstname + " " + lastname);
    }

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    static void companyInfo( )                                        //static method
    {
        System.out.println("Company: "   + companyName);                     //OK - accessing static field 
        System.out.println("Company: "   + Employee.companyName);            //OK

        System.out.println("Emp count: " + getEmployeeCount() );            //OK - accessing static method
        System.out.println("Emp count: " + Employee.getEmployeeCount() );   //OK

//      System.out.println("Firstname: " + firstname);                      //Not OK accessing instance field
//      System.out.println("Fullname:  " + getFullname("Mr.") );            //Not OK

    }
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    public String toString()                                          //instance method
    {
        String data = "\n Company: "   + companyName                        //OK - accessing static field
                    + "\n Company: "   + Employee.companyName               //OK
                    + "\n Company: "   + this.companyName                   //OK

                    + "\n Emp count: " + getEmployeeCount( )                //OK - accessing static method
                    + "\n Emp count: " + Employee.getEmployeeCount( )       //OK
                    + "\n Emp count: " + this.getEmployeeCount( )           //OK

                    + "\n Firstname: " + firstname                          //OK - accessing instance field
                    + "\n Firstname: " + this.firstname                     //OK

                    + "\n Fullname: "  + getFullname("Mr.")                 //OK - accessing instance method
                    + "\n Fullname: "  + this.getFullname("Mr.");           //OK

        return(data);
    }
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
}