Question: Java Project: Implement the object model shown in Figure 1-25 to implement a small banking application. Create five classes: Bank , BankAccount , SavingsAccount ,

Java Project:
Implement the object model shown in Figure 1-25 to implement a small banking application. Create five classes: Bank, BankAccount,SavingsAccount, CheckingAccount, and Customer. Bank Should be a singleton class. For simplicity, the bank stores bank accounts in one array and customers in another. All bank accounts are savings accounts or checking accounts, and any customer may have zero or one account of each type.
The difference between the two accounts affects only the withdraw method. Thedeposit method simply increments the balance. The withdraw method decrements the balance, but cannot always do so. A customer can withdraw from a SavingsAccount only an amount less than or equal to the current balance. For aCheckingAccount the logic is:
Withdraw the amount if less than or equal to the balance.
If the customer has a SavingsAccount, and the SavingsAccount has enough money to cover the shortfall in the CheckingAccount, transfer enough money from saving to checking to cover the withdrawal. Then withdraw the money.
If the customer has no savings account, or the total of both accounts is less than the withdrawal amount, issue an InsufficientFundsException exception(just print message if Exception has not been covered).
Add a main method to the Bank class to test. Create one customer and give that customer a savings account. Try a deposit and withdrawal. Give the customer a checking account and try another deposit. Try withdrawals that succeed without a transfer, that transfer founds from savings, and for which there are insufficient funds.
BankAccount Bank account No account List has 0..n Owner customer List balance addCustomer deposit abstract withdraw add Account has Savings Account CheckingAccount withdraw withdraw 0..n Customer 0..1 0..1 savings Acct has checking Acct has add Savings Account addCheckingAccount Figure 1-25 Object model for a banking application
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
