菜鸟技术问题

a422325532 2011-04-06 07:15:48
class Point{
private double x;
private double y;
Point ( double x1, double y1 ){
x = x1;
y = y1;
}
public double getX(){ return x;}
public double getY(){ return y;}
public void setX( double i ){ x = i; }
public void setY( double i ){ y = i; }

}
class Circle{
private Point o;//复用
Circle (Point p, double r){
o = p;
}
/*圆心定在原点上*/
Circle (double r){
o = new Point( 0.0,0.0);//圆心定在原点
} //重载
boolean contains(Point p){
double x = p.getX() - o.getX();
double y = p.getY() - o.getY();
else return true;
}
public void setO( double x, double y){
o.setX(x);
o.setY(y);

}
public Point getO(){ return o;}
public double area(){
}
}
public class TestCircle{
public static void main(String[] args){
Circle c1 = new Circle(new Point(1.0,2.0),2.0);
Circle c2 = new Circle(5.0);
System.out.println("c1 Area is " +c1.area());
System.out.println("c2 Area is " +c2.area());
c1.setO(5,6);
System.out.println("c1 area = " +c1.area());
System.out.println("c2 area = " +c2.area());
Point p1 = new Point(5.2, 6.3);
System.out.println(c1.contains(p1));
System.out.println(c1.contains(new Point(10.0, 9.0)));
}
}

D:\java1>javac TestCircle.java
TestCircle.java:48: 找不到符号

System.out.println("c1:("+c1.getO().getX()+","+c1.getO.g
^
TestCircle.java:49: 找不到符号

System.out.println("c2:("+c2.getO().getX()+","+c2.getO.g
^
2 错误

D:\java1>

...全文
49 1 打赏 收藏 转发到动态 举报

1 条回复

shahuangking 2011-04-06
• 打赏
• 举报

static class Circle
static class Point

23,407

• 近7日
• 近30日
• 至今