/*This class is used to store salary info. for a single employee.
Note: this is an incorrect version we discussed in class--the setEmpInfo()
method has a subtle bug.  I'm not going to point it out here, but hopefully people can
find it and see what happens (see mainTester for the "solution")*/

public class Employee {
  private String name;
  private int salary; 

  //this needs to be modified (think about why)  
  public Employee(String name, int salary) {
    this.name = name;
    this.salary = salary;
  }
  public void printEmpInfo() {
    System.out.println("Employee: " + name + ", salary: " + salary + ",000");
  }  
  
  //the new material is here
  public boolean equals(Employee emp2) {
    
    //both the names and the salaries must be equal if "this" and "emp2" are equal
    //notice we can compare the primitive (salary) directly, but the reference (String)
    //must be compared using .equals()
    
    return( emp2.name.equals(name) && emp2.salary == salary);
  }
  
  //mutators and accessors
  public void setEmpInfo(String name, int salary) {
    this.name = name;
    this.salary = salary;
  }
}
