Java Reference
In-Depth Information
public class Transaction {
// Constructor
public Transaction(Account account, TransactionType type, int
amount) {
this.account = account;
this.type = type;
this.amount = amount;
}
public Account getAccount() {
return account;
}
public TransactionType getTransactionType() {
return type;
}
public int getAmount() {
return amount;
}
@Override
public String toString() {
return type + " A//C: " + account + ": $" + amount;
}
private Account account;
private int amount;
private TransactionType type;
}
Directory "BankOperation 1"
How It Works
The type of transaction is specified by the TransactionType enumeration. A transaction records the
amount for the transaction and a reference to the account to which it applies, so a Transaction object
specifies a complete transaction. The methods are very straightforward, just accessor methods for the
data members that are used by the Bank object, plus the toString() method overload in case you need
it.
TRY IT OUT: Defining a Bank Account
You can define an account by the following class type:
Search WWH ::




Custom Search