Guest User

Untitled

a guest
May 4th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author Tomaz Lavieri
  4.  */
  5. public class Point3D {
  6.     private final long x;
  7.     private final long y;
  8.     private final long z;
  9.  
  10.     public Point3D() {
  11.         x = 0;
  12.         y = 0;
  13.         z = 0;
  14.     }
  15.  
  16.     public Point3D(long x, long y, long z) {
  17.         this.x = x;
  18.         this.y = y;
  19.         this.z = z;
  20.     }
  21.  
  22.     public long getX() {
  23.         return x;
  24.     }
  25.  
  26.     public long getY() {
  27.         return y;
  28.     }
  29.  
  30.     public long getZ() {
  31.         return z;
  32.     }
  33.  
  34.     @Override
  35.     public boolean equals(Object obj) {
  36.         if (obj == null) {
  37.             return false;
  38.         }
  39.         if (getClass() != obj.getClass()) {
  40.             return false;
  41.         }
  42.         final Point3D other = (Point3D) obj;
  43.         if (this.x != other.x) {
  44.             return false;
  45.         }
  46.         if (this.y != other.y) {
  47.             return false;
  48.         }
  49.         if (this.z != other.z) {
  50.             return false;
  51.         }
  52.         return true;
  53.     }
  54.  
  55.     @Override
  56.     public int hashCode() {
  57.         int hash = 5;
  58.         hash = -7 * hash + (int)this.x;
  59.         hash = 2 * hash + (int)this.y;
  60.         hash = 3 * hash + (int)this.z;
  61.         return hash;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment