当座預金口座と普通預金口座から資金を送金できる銀行口座が必要な任務があります。トランザクションは ArrayList に保存され、ユーザーがいつ資金を送金するかを指定できるように設定されます。小切手と普通預金の銀行口座クラスは正常に動作しますが、作成した TransferService クラスは NetBeans で正しくコンパイルされません。
ヒントはエラーを修正していないようです。エラーが発生します:
トランザクションは抽象的で、インスタンス化できません。
この問題を解決するにはどうすればよいですか?
import java.util.ArrayList;
import java.util.Date;
import javax.transaction.Transaction;
public class TransferService {
private Date currentDate;
private ArrayList<Transaction> completedTransactions;
private ArrayList<Transaction> pendingTransactions;
public void TransferService(){
this.currentDate = new Date();
this.completedTransactions = new ArrayList<Transaction>();
this.pendingTransactions = new ArrayList<Transaction>();
}
public TransferService(BankAccount to, BankAccount from, double amount, Date when) throws InsufficientFundsException(){
if (currentDate.after(when)){
try(
from.withdrawal(amount);
to.deposit(amount);
completedTransactions.add(new Transaction(to, from, this.currentDate, Transaction.TransactionStatus.COMPLETE));
} catch (InsufficientFundsException ex){
throw ex;
}
} else {
pendingTransactions.add(new Transaction(to, from, null, Transaction.TransactionStatus.PENDING));
}
}
private static class InsufficientFundsException extends Exception {
public InsufficientFundsException() {
System.out.println("Insufficient funds for transaction");
}
}