        // A cloneable point class.
        // A class to hold details of an (x,y) coordinate.
public class Point implements Cloneable {
    public Point(int x, int y){
        this.x = x;
        this.y = y;
    }

    public Point(Point p){
        this(p.getX(),p.getY());
    }

        // Return a string representation of the (x,y) pair.
    public String toString(){
        return "("+getX()+","+getY()+")";
    }

        // Return true if o is a Point with the same (x,y)
        // pair as this Point.
    public boolean equals(Object o){
        if(o == this){
            // The same object.
            return true;
        }
        else if(o == null){
            return false;
        }
        else if(o instanceof Point){
            Point p = (Point) o;
            return getX() == p.getX() && getY() == p.getY();
        }
        else{
            return false;
        }
    }

    public Object clone() {
        try{ 
            return super.clone();
        }
        catch(CloneNotSupportedException e){
            // This should never happen!
            throw new Error("Cloning error in Point: "+e);
        }
    }
    public int getX(){
        return x;
    }

    public int getY(){
        return y;
    }

    private final int x,y;
}
