我有两个班:FinishButton
和ChangeSpeedButton
。 FinishButton
是父类,但它来自不同的包,它是另一个类的子类。它有2个构造函数:
public class FinishButton extends Button {
public FinishButton(Point...points) {
super(Response.SLOW,Type.HOLD,points);
}
public FinishButton() {
this(new Point(width-75,height-75),
new Point(width-75,height-15),
new Point(width-15,height-15),
new Point(width-15,height-75));
}
public void function() {
nextPanel();
}
public void draw(Graphics g) {
super.draw(g);
this.xpoints[0] = 0;
g.setColor(Defaults.GRAPHIC_COLOR);
int[] xPoints = {
width-45-(int)((20*Math.sqrt(3))/2),
width-45-(int)((20*Math.sqrt(3))/2),
width-45+(int)((20*Math.sqrt(3))/2)
},
yPoints = {
height-65,height-25,height-45
};
int nPoints = 3;
g.fillPolygon(xPoints, yPoints, nPoints);
}
}
这些类正在进行中,但ChangeSpeedButton
看起来像这样:
public class ChangeSpeedButton extends FinishButton {
public ChangeSpeedButton() {
super(new Point(width/2-30,height-75),
new Point(width/2-30,height-15),
new Point(width/2+30,height-15),
new Point(width/2+30,height-75));
}
}
奇怪的是FinishButton
在重载自己的构造函数时完美地处理了varargs,但由于某种原因在ChangeSpeedButton
的构造函数上,Eclipse告诉我
“删除匹配'FinishButton()'或”更改构造函数'FinishButton()'的参数:添加参数'Point,Point,Point,Point'“。
有谁知道为什么它在ChangeSpeedButton
上给我一个错误?
编辑:我添加了完整的课程。根据要求,这里是Point
类:
public class Point {
private double x,y;
public double getX() { return x; }
public double getY() { return y; }
public Point() {
this(0,0);
}
public Point(double x,double y) {
this.x = x;
this.y = y;
}
public String toString() {
return "Point: ("+x+", "+y+")";
}
}
也许这与Button类是嵌套类这一事实有关?
哦,我的天啊。我太笨了我打开了2个FinishButton文件,即使我保存了其中一个正确的更改,ChangeSpeedButton只查看过时的文件。