Skip to content
Snippets Groups Projects

Point: Implement hashCode

Merged Alexander O'Brien requested to merge obrienad/bagel-public:hashcode into master
1 file
+ 7
0
Compare changes
  • Side-by-side
  • Inline
package bagel.util;
import java.util.Objects;
/**
* Immutable class that represents a 2D point in space.
*/
@@ -42,6 +44,11 @@ public class Point {
}
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
public double distanceTo(Point b) {
return asVector().sub(b.asVector()).length();
}
Loading