public class Point implements Cloneable
{
  private int x;
  private int y;
  
  public Point ()
  {
    this (0, 0);
  }
  
  public Point (int x, int y)
  {
    this.x = x;
    this.y = y;
  }
  
  public int getX ()
  {
    return x;
  }
  
  public int getY ()
  {
    return y;
  }
  
  public void setLocation (int x, int y)
  {
    this.x = x;
    this.y = y;
  }
  
  public double distance (Point p)
  {
    int dx = x - p.x;
    int dy = y - p.y;
    return Math.sqrt (dx * dx + dy * dy);
  }
  
  public double distanceFromOrigin ()
  {
    return distance (new Point ());
  }
  
  public boolean equals (Object obj)
  {
    if (!(obj instanceof Point))
      return false;
    Point p = (Point) obj;
    return x == p.x && y == p.y;
  }
  
  public Point clone ()
  {
    try
    {
      Point p = (Point) super.clone ();
      return p;
    }
    catch (CloneNotSupportedException e)
    {
      throw new RuntimeException ("Cloneable interface not implemented");
    }
  }
  
  public String toString ()
  {
    return "(" + x + ", " + y + ")";
  }
}
