关于Rectangle 类
这个类import java.awt.*;
public class ball{
protected Rectangle location;
protected double dx;
protected double dy;
protected Color color;
public ball(int x,int y,int r){
location =new Rectangle(x-r,y-r,2*r,2*r);
dx=0;
dy=0;
color=Color.blue;
}
public void setColor(Color newColor){
color=newColor;
}
public void setMotion(double ndx,double ndy){
dx=ndx;
dy=ndy;
}
public int radius(){
return location.width/2;
}
public int x(){
return location.x+radius();
}
public int y(){
return location.y+radius();
}
public double xMotion(){
return dx;
}
public double yMotion(){
return dy;
}
public Rectangle region(){
return location;
}
public void moveTO(int x,int y){
location.setLocation(x,y);
}
public void move(){
location.translate((int)dx,(int)dy);
}
public void paint(Graphics g){
g.setColor(Color.red);
g.fillOval(location.x,location.y,location.width,location.height);
}
}
里面关于location.x,location.y,location.width,location.heigth这几个变量的引用都在编译中显示错了,我搞不清楚为什么??