ベローからクラスを作成して拡張しようとしていますが、Eclipseから「トークン "{"の構文エラー、{このトークンの後に期待されます」というエラーメッセージが表示されます
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
public class Ship {
protected int hull;
protected int shield;
protected Vector2 velocity;
protected int energy;
protected Texture shipTexture;
protected Vector2 position;
public Texture getShipTexture() {
return shipTexture;
}
public void setShipTexture(Texture shipTexture) {
this.shipTexture = shipTexture;
}
public Vector2 getPosition() {
return position;
}
public void setPosition(Vector2 position) {
this.position = position;
}
public int getHull() {
return hull;
}
public void setHull(int hull) {
this.hull = hull;
}
public int getShield() {
return shield;
}
public void setShield(int shield) {
this.shield = shield;
}
public Vector2 getVelocity() {
return velocity;
}
public void setVelocity(Vector2 velocity) {
this.velocity = velocity;
}
public int getEnergy() {
return energy;
}
public void setEnergy(int energy) {
this.energy = energy;
}
}
最初のブラケットの後のこのクラスの場合:
public class Frigate extends Ship {
this.hull = 10;
this.shield = 10;
}
同じ変数とアクションで異なる値を持つ「船」を設定するより良い方法はありますか?