Guest User

Untitled

a guest
Oct 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package com.citizens.Pathfinding;
  2.  
  3. public final class Point {
  4. public final int x;
  5. public final int y;
  6. public final int z;
  7.  
  8. public Point(int x, int y, int z) {
  9. this.x = x;
  10. this.y = y;
  11. this.z = z;
  12. }
  13.  
  14. @Override
  15. public int hashCode() {
  16. final int prime = 31;
  17. int result = 1;
  18. result = prime * result + x;
  19. result = prime * result + y;
  20. result = prime * result + z;
  21. return result;
  22. }
  23.  
  24. @Override
  25. public boolean equals(Object obj) {
  26. if (this == obj)
  27. return true;
  28. if (obj == null)
  29. return false;
  30. if (getClass() != obj.getClass())
  31. return false;
  32. Point other = (Point) obj;
  33. return x == other.x && y == other.y && z == other.z;
  34. }
  35.  
  36. @Override
  37. public String toString() {
  38. return "Point [x=" + x + ", y=" + y + ", z=" + z + "]";
  39. }
  40.  
  41. public int distanceSquared(Point second) {
  42. int diffX = second.x - this.x;
  43. int diffY = second.y - this.y;
  44. int diffZ = second.z - this.z;
  45. return diffX * diffX + diffY * diffY + diffZ * diffZ;
  46. }
  47. }
Add Comment
Please, Sign In to add comment