本帖最后由 樊占江 于 2012-8-6 21:27 编辑
class Point{
double x;
double y;
Point(double x1, double y1){
x = x1;
y = y1;
}
double getDistance(Point o){
return (x-o.x)*(x-o.x)+(y-o.y)*(y-o.y);
}
} class Circle{
static private Point o;
static private double radius;
Circle (Point p, double r){
o = p;
radius = r;
}
public static void main(String[] args){
Point p = new Point(3,4);
p.getDistance(p);
Circle c = new Circle(p, 10);
double q = radius*radius;
if(p.getDistance(p)>q){
System.out.println("该点在圆内");
}
else{
System.out.println("该点不在圆内");
}
}
}
结果总是不在圆内,我不知道那里出问题呢?各位帮我看看吧 思路什么的,还有哪里不对。
谢谢 |
|