//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 3.1 on page 71

public class Point3D extends Point
{ protected double z;
  public Point3D(double x, double y)
  { this.x = x;
    this.y = y;
    this.z = 0;
  }
  public Point3D(double x, double y, double z)
  { this.x = x;
    this.y = y;
    this.z = z;
  }
  public Point3D(Point3D q)
  { this.x = q.x;
    this.y = q.y;
    this.z = q.z;
  }
  public double getZ()
  { return z;
  }
  public void setLocation(double x, double y, double z)
  { this.x = x;
    this.y = y;
    this.z = z;
  }
  public void translate(double dx, double dy, double dz)
  { x += dx;
    y += dy;
    z += dz;
  }
  public boolean equals(Object object)
  { if (object == this) return true;
    if (object.getClass() != this.getClass()) return false;
    if (object.hashCode() != this.hashCode()) return false;
    Point3D point = (Point3D)object;
    return (x == point.x && y == point.y && z == point.z);
  }
  public int hashCode()
  { return (new Double(x)).hashCode() + (new Double(y)).hashCode()
                                      + (new Double(z)).hashCode();
  }
  public String toString()
  { return new String("(" + (float)x + ","  + (float)y
                          + ","  + (float)z + ")");
  }
}