class Worker{
private String name;
private int age;
private float salary;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if(!obj.getClass().isInstance(Worker.class))
return false;
else
{
Worker temp = (Worker)obj;
boolean b1 = this.getName().equals(temp.getName());
boolean b2 = (this.getAge()==temp.getAge());
boolean b3 = (this.getSalary()==temp.getSalary());
return b1&&b2&&b3;
}
}
} |