java调用方法找不到符号
简单编了一个验证点是否在圆内,实在想不出问题出在哪里,发上来求助一下classPoint{privatedoublex;privatedoubley;Point(doub...
简单编了一个验证点是否在圆内,实在想不出问题出在哪里,发上来求助一下
class Point{
private double x;
private double y;
Point(double _x, double _y){
x = _x;
y = _y;
}
double getX(){return x;}
double getY(){return y;}
void setX(double i){x = i;}
void setY(double i){y = i;}
}
class Circle{
public Point o;
public double radius;
Circle(Point p, double r){
o = p;
radius = r;
}
Circle(double r){
o = new Point(0.0, 0.0);
radius = r;
}
public Point getO(){return o;}
public double getR(){return radius;}
boolean checkPoint(Point p){
double _x = o.getX() - p.getX();
double _y = o.getY() - p.getY();
if (radius*radius > _x*_x + _y*_y)
return true;
else
return false;
}
}
public class CheckPoint{
public static void main(String[] args){
Circle c1 = new Circle(new Point(1.0, 2.0), 3.0);
Point p1 = new Point(3.0, 2.0);
System.out.println(c1.CheckPoint(p1));
CheckPoint.java:45: 错误: 找不到符号
System.out.println(c1.CheckPoint(p1));
^
符号: 方法 CheckPoint(Point)
位置: 类型为Circle的变量 c1 展开
class Point{
private double x;
private double y;
Point(double _x, double _y){
x = _x;
y = _y;
}
double getX(){return x;}
double getY(){return y;}
void setX(double i){x = i;}
void setY(double i){y = i;}
}
class Circle{
public Point o;
public double radius;
Circle(Point p, double r){
o = p;
radius = r;
}
Circle(double r){
o = new Point(0.0, 0.0);
radius = r;
}
public Point getO(){return o;}
public double getR(){return radius;}
boolean checkPoint(Point p){
double _x = o.getX() - p.getX();
double _y = o.getY() - p.getY();
if (radius*radius > _x*_x + _y*_y)
return true;
else
return false;
}
}
public class CheckPoint{
public static void main(String[] args){
Circle c1 = new Circle(new Point(1.0, 2.0), 3.0);
Point p1 = new Point(3.0, 2.0);
System.out.println(c1.CheckPoint(p1));
CheckPoint.java:45: 错误: 找不到符号
System.out.println(c1.CheckPoint(p1));
^
符号: 方法 CheckPoint(Point)
位置: 类型为Circle的变量 c1 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询