/** * * A Point has an x and a y coordinate. * * @author Benjamin Shults * @version 1 */ public class Point implements Cloneable { /** * The x coordinate of the point. */ protected double x; /** * The y coordinate of the point. */ protected double y; public boolean equals(Object o) { if (o instanceof Point) { Point arg = (Point) o; return this.x == arg.x && this.y == arg.y; } else return false; } public Point clone() { try { return (Point) super.clone(); } catch (CloneNotSupportedException e) { throw new Error("Clone is supported.", e); } } public int hashCode() { return (int) (Double.doubleToLongBits(this.x) + Double.doubleToLongBits(this.y)); } public String toString() { return "(" + x + ", " + y + ")"; } /** * Construct the origin. I.e., the point (0, 0). */ public Point() { this(0.0, 0.0); } /** * Construct the point (x, y). * @param x the x-coordinate of the point to be constructed. * @param y the y-coordinate of the point to be constructed. */ public Point(double x, double y) { this.x = x; this.y = y; } } // Point