Home
Account class
This class handles the data and processes the logic of the account entity in the ITSO Bank application. On an account, many transactions can be held, therefore it handles the relationship with the Transaction class. Example | 4 shows some of the relevant Java source code in simplified format of the Account class.
Example 8-4 Account class
package itso.rad75.bank.model;public class Account implements Serializable {public Account(String accountNumber, BigDecimal balance) {this.setAccountNumber(accountNumber);this.setBalance(balance);this.setTransactions(new ArrayList<Transaction>());}public void processTransaction(BigDecimal amount, String transactionType)throws InvalidTransactionException {......if (TransactionType.CREDIT.equals(transactionType)) {transaction = new Credit(amount);}else if (TransactionType.DEBIT.equals(transactionType)) {transaction = new Debit(amount);......}......}
ibm.com/redbooks