public class Coordinate2D
{
    private int x, y;

    public Coordinate2D()
    {
        x = 0;
        y = 0;
    }

    public Coordinate2D(int initX, int initY)
    {
        x = initX;
        y = initY;
    }

    public int getX()
    {
        return x;
    }

    public int getY()
    {
        return y;
    }

    public void setX(int newX)
    {
        x = newX;
    }

    public void setY(int newY)
    {
        y = newY;
    }

    public double getDistance(Coordinate2D otherCoor)
    {
        int xSqrd = this.getX() - otherCoor.getX();
        xSqrd *= xSqrd;

        int ySqrd = this.getY() - otherCoor.getY();
        ySqrd *= ySqrd;

        return Math.sqrt(xSqrd + ySqrd);
    }

    public String toString()
    {
        return "(" + getX() + ", " + getY() + ")";
    }

    public boolean equals(Object other)
    {
        if(this == other)
            return true;

        if( ! (other instanceof Coordinate2D) )
            return false;

        Coordinate2D otherC = (Coordinate2D) other;
        return x == otherC.x && y == otherC.y;
    }

    public int hashCode()
    {
        return x * 31 + y * 37;
    }
}
