我有2个类: 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 告诉我到
"删除参数以匹配'finishtton()'"或"更改 构造函数'finishtton()':添加参数 "点,点,点,点"。
有人知道为什么它会给我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+")";
}
}
也许与按钮类是嵌套类的事实有关?
哦,我的天哪。我很愚蠢。我打开了2个finishtton文件,即使我以正确的更改保存了其中一个文件,ChangespeedButton也只查看了过时的文件。