
// Employee.java
// Andrew Davison, ad@coe.psu.ac.th, May 2023

/*  Used by CollectionUtilsTester.java,
    PredicatesListTester,
    and ClosureTester.java
*/


public class Employee implements Comparable<Employee>
{
  private String name, gender, country;
  private double salary;


  public Employee(String name, String gender, 
                  double salary, String country)
  {
    this.name = name;
    this.gender = gender;
    this.salary = salary;
    this.country = country;
  }


  public Employee(String name, String gender, 
                  String country)
  { 
    this.name = name;
    this.gender = gender;
    salary = 0;
    this.country = country;
  }


  public Employee(String name, String gender, 
                  double salary)
  {
    this.name = name;
    this.gender = gender;
    this.salary = salary;
    country = "USA";
  }


  public String getName()
  {  return name;   }

  public void setName(String name)
  {  this.name = name;   }


  public String getGender() 
  {  return gender;   }

  public void setGender(String gender) 
  {  this.gender = gender;   }


  public double getSalary()
  {  return salary;   }

  public void setSalary(double salary)
  {  this.salary = salary;   }


  public String getCountry()
  {  return country;   }

  public void setCountry(String country)
  {  this.country = country;   }


  public int hashCode()
  {  return 31 + ((name == null) ? 0 : name.hashCode());  } 


  public boolean equals(Object obj)
  // test equality based on the name
  {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Employee other = (Employee) obj;
    if (name == null) {
      if (other.name != null)
        return false;
    }
    else if (!name.equals(other.name))
      return false;
    return true;
  } /* equals */


  public int compareTo(Employee o)
  {  return this.name.compareTo(o.getName());   }


  public String toString()
  {   return "emp:" + this.getName();   }

}  // end of Employee class