鑑於以下代碼:如何解決「令牌摘要中的語法錯誤」錯誤?
package core;
public abstract class GeometricElement {
private float area;
public abstract void calculateArea(); //will be implemented in subclasses
public float getArea()
{
this.calculateArea();
return area;
}
}
package core;
public class abstract PerfectPolygon extends GeometricElement
{
public abstract void calculateArea();
private float length;
private int sides;
public float getRadius() { return this.length; }
public float getSides() { return this.sides; }
public void setRadius(float newLength) {this.length = newLength;}
public void setSides(float newSides) {this.length = newSides;}
}
package core;
public class PerfectTriangle extends PerfectPolygon {
PerfectTriangle() {}
public void calculateArea() { }
}
package core;
public class Square extends PerfectPolygon {
Square() {}
public void calculateArea() {}
}
包芯;
public class Circle extends GeometricElement
{
private float radius;
Circle() {}
public float getRadius() { return this.radius; }
public void setRadius(float newRadius) {this.radius = newRadius;}
public void calculateArea() {}
}
我在我的項目的開始,但是,我似乎無法繼續,因爲在Eclipse拋出的錯誤: 1)「語法錯誤令牌‘抽象’,刪除此令牌」中類PerfectPolygon 2)「PerfectPolygon不能被解析爲一個類型」類廣場 3)類「PerfectPolygon不能被解析爲一個類型」 PerfectTriangle
請注意,我寫的幾乎沒有代碼,我剛剛開始編寫代碼,但由於某些原因,Eclipse不會允許編譯這些小代碼。 任何想法爲什麼? 我會感激你的幫助
問候, 羅恩
謝謝!!很多 ! – ron
@ron請嘗試以下操作:http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – alf