I am trying to write an eqauls(Object compared) method for a Person class which can be used to compare the similarity of people. The comparison should take into account the equality of all the variables of a person (birthday included). What is wrong with the way I am comparing their birthdays?
NB! Recall that you cannot compare two birthday objects with equality signs! What I have done is:
public boolean equals (Object compared){
if(this == compared){
return true;
}
if(!(compared instanceof Person)){
return false;
}
Person comparedPerson = (Person) compared;
if(this.name.equals(comparedPerson.name) && this.birthday.equals(comparedPerson)&& this.height == comparedPerson.height && this.weight== comparedPerson.weight){
return true;
}
return false;