我有一個抽象類GeometricObject,它由基類Rectangle擴展。在父,我提供了兩個構造函數:Java - 構造函數未定義
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** Construct a default geometric object */
protected GeometricObject() {
dateCreated = new java.util.Date();
}
/** Construct a geometric object with color and filled value */
protected GeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}
在矩形類,我創建了另一個構造函數,這是應該調用GeometricObject參數的構造函數。糾正我,如果我錯了,但這是給「矩形」對象的「顏色」和「填充」值的正確方法。
public class Rectangle extends GeometricObject implements Comparable<Rectangle>{
private double width;
private double height;
public Rectangle() {
}
**public Rectangle(double width, double height, String color, boolean filled) {
super(color, filled);
this.width = width;
this.height = height;
}**
然而,Eclipse的給我下面的錯誤超級旁(顏色,填充)聲明: 「構造GeometricObject(字符串,布爾)未定義」
我缺少什麼?
似乎在這裏很好 - http://ideone.com/msFeyz。你能構建一個[最小測試用例](http://stackoverflow.com/help/mcve)嗎? –
不可思議。在您的評論之後,我添加了一個新的測試類並使用構造函數創建了一個實例,並且突然間錯誤消失了。神祕的IDE ......謝謝! – DR29