Customer と Account という 2 つのクラスがあります。Customer クラスには、顧客の名前と顧客のアカウントがあります。アカウントは配列にあります。
private Account accounts[] = new Account[2];
プログラムの開始時に、普通預金口座が設定されます。
public Customer(){
account[0] = new Account("savings");
}
Account クラスのコンストラクターは次のとおりです。
public Account(String name){
this.name = name;
}
Customer にクレジット アカウントを追加するメソッドがあります。
private void addAccount(){
account[1] = new Account("credit");
}
そして今、Accountクラスで貯蓄からクレジットに送金する必要があります
Customer クラスの 2 つの異なるアカウントにアクセスするにはどうすればよいですか。試してみましたが、NullpointerExceptions で失敗しました
ありがとうございました。