Commit ad7f24bb authored by Adam Blank's avatar Adam Blank
Browse files

Merge branch 'patch-1' into 'master'

Update Point.java to properly override equals

See merge request !2
1 merge request!2Update Point.java to properly override equals
Pipeline #28868 failed with stage
in 0 seconds
Showing with 7 additions and 5 deletions
+7 -5
......@@ -15,10 +15,12 @@ public class Point {
* Returns true if the point passed has the same x and y coordinate as
* this point, or false otherwise.
*/
public boolean isEqual(Point point) {
if (point == null) return false;
int x = point.x;
int y = point.y;
return (this.x == x && this.y == y);
@Override
public boolean equals(Object o) {
if (!(o instanceof Point)) {
return false;
}
Point p = (Point) o;
return (this.x == p.x && this.y == p.y);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment