別のクラスから継承するクラスに取り組んでいますが、「シンボル コンストラクター Account() が見つかりません」というコンパイラ エラーが発生します。基本的に私がやろうとしているのは、Account から拡張するクラス InvestmentAccount を作成することです - Account は、お金を引き出し/入金する方法で残高を保持することを目的としていますが、InvestmentAccount は似ていますが、残高は株価によってどのように決定されるかを示す株式に保存されます特定の金額を指定すると、多くの株式が預け入れまたは引き出されます。サブクラス InvestmentAccount の最初の数行 (コンパイラが問題を指摘したあたり) を次に示します。
public class InvestmentAccount extends Account
{
protected int sharePrice;
protected int numShares;
private Person customer;
public InvestmentAccount(Person customer, int sharePrice)
{
this.customer = customer;
sharePrice = sharePrice;
}
// etc...
Person クラスは、別のファイル (Person.java) に保持されます。スーパークラス Account の最初の数行は次のとおりです。
public class Account
{
private Person customer;
protected int balanceInPence;
public Account(Person customer)
{
this.customer = customer;
balanceInPence = 0;
}
// etc...
コンパイラが Account クラスから Account のシンボル コンストラクターを読み取るだけではない理由はありますか? それとも、すべてを継承するように指示する InvestmentAccount 内の Account の新しいコンストラクターを定義する必要がありますか?
ありがとう