Commit dd983741 authored by Hale Obernolte's avatar Hale Obernolte
Browse files

Update Point.java to properly override equals

parent 9cd21dd5
1 merge request!4Update Point.java to properly override equals
Pipeline #28866 failed with stage
in 0 seconds
Showing with 5 additions and 18 deletions
+5 -18
......@@ -11,29 +11,16 @@ public class Point {
this.parent = null;
}
/*
* 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);
}
/*
* Returns true if the point passed has the same x and y coordinate as
* this point, or false otherwise.
*/
@Override
public boolean equals(Object point) {
if (!(point instanceof Point)) {
return false;
public boolean equals(Object o) {
if (!(o instanceof Point)) {
return false;
}
Point p = (Point) point;
int x = p.x;
int y = p.y;
return (this.x == x && this.y == y);
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