public class Point3D extends Point { private int z; public Point3D() { this(0, 0, 0); } public Point3D(int x, int y, int z) { // constructor super(x, y); this.z = z; } // Returns true if o refers to a Point3D object with the same x/y/z // coordinates as this Point3D; otherwise returns false. public boolean equals(Object o) { if (o != null && getClass() == o.getClass()) { Point3D p = (Point3D) o; return super.equals(o) && z == p.z; } else { return false; } } public int getZ() { return z; } public void translate(int dx, int dy, int dz) { super.translate(dx, dy); z += dz; } public String toString() { // for printing return "(" + getX() + ", " + getY() + ", " + z + ")"; } }