Método igual para objetos
Estoy tratando de escribir un método igual para los objetos que compara sus campos y devuelve verdadero si son iguales.
private int x, y, direction;
private Color color;
public boolean equals(Ghost other){
if (this.x == other.x && this.y == other.y &&
this.direction == other.direction && this.color == other.color)
return true;
else
return false;
}
¿Qué podría estar mal con esto?