Home
Transaction class
This class handles the data and processes the logic of a transaction in the ITSO Bank application. A transaction can be either credit or debit type; that is why both inherit the transaction class structure. Example | 5 shows some of the relevant Java source code in simplified format of the Transaction class.
Example 8-5 Transaction class
package itso.rad75.bank.model;public abstract class Transaction implements Serializable {static int transactionCtr = 1; // to increment transactionIdpublic Transaction(BigDecimal amount) {this.setTimeStamp(new Timestamp(System.currentTimeMillis()));this.setAmount(amount);this.setTransactionId(transactionCtr++);}public abstract String getTransactionType();public abstract BigDecimal process(BigDecimal accountBalance)throws InvalidTransactionException;......}
ibm.com/redbooks