随笔-16  评论-0  文章-0  trackbacks-0
class Point
  {
    double x, y;
    Point()
      {
       x = Math.random();
       y = Math.random();
      }
    Point(double x, double y)
      {
       this.x = x;
       this.y = y;
      }
    double r()
      {
       return Math.sqrt(x*x + y*y);
      }
    double theta()
      {
        return Math.atan2(y, x);
      }
    double distance(Point p)
      {
        double dx = x - p.x, dy = y - p.y;
        return Math.sqrt(dx*dx + dy*dy);
      }
    public String toString()
      {
        return "(" + x + "," + y + ")";
      }
  }
posted on 2006-07-30 10:08 尨奇 阅读(150) 评论(0)  编辑  收藏 所属分类: algorithms in java