比较对象练习(Java)

希望这不会让我看起来像个白痴,但我似乎在一次简单的练习中失败了,在这个简单的练习中,我必须比较两个对象以检查它们是否相等,下面是我的Java类以及我收到的错误消息从运动。有人知道如何解决吗?提前致谢。

import java.util.Objects;

public class Person {

    private String name;
    private SimpleDate birthday;
    private int height;
    private int weight;

    public Person(String name, SimpleDate birthday, int height, int weight) {
        this.name = name;
        this.birthday = birthday;
        this.height = height;
        this.weight = weight;
        hashCode();
    }
    public String getName(){
        return this.name;
    }
    public SimpleDate getBirthday(){
        return this.birthday;
    }
    public Integer getHeight(){
        return this.height;
    }
    public Integer getWeight(){
        return this.weight;
    }
    // implement an equals method here for checking the equality of objects
    @Override
    public boolean equals(Object compared){
        return this==compared;
    }
}

Error message

评论