Ad
  • Default User Avatar

    I found the definition of the class Point may be wrong. The type of x is double, and the method equals use "==" to judge whether a.x equals to b.x. I thought it will always be false.
    In the context, I thought may type int be more fit for the issue! As following:

    @Override
    public boolean equals(Object obj) {
    if (obj instanceof Point) {
    Point other = (Point) obj;
    return x == other.x && y == other.y;
    } else {
    return false;
    }
    }