Skip to content
Snippets Groups Projects

Point: Implement hashCode

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