In this assignment you will build a class to represent bank accounts and another which represents a bank to hold them. Please note that your bank account and bank classes should contain absolutely no
System.out.println()s in them.Part One
Build a class to represent a bank account. It needs to contain instance variables and methods which allow identification of the account (by name or ID, for example), deposits and withdrawals from the account (no overdrafts, please!) and queries to its balance. The withdrawal function should return the actual amount withdrawn.
Test this function appropriately in a main().
Part Two
Build a class to represent a bank. A bank instance needs to be able to hold up to 2000 bank account objects, be able to create a new bank account, give access to a particular bank account object (looking it up by name or id), and return the total balance of the accounts in the bank. It must also be able to produce an account summary of all the accounts. The account summary will be returned as a String object, including the appropriate formatting to make a pleasant looking chart.
Part Three
Build a large main to run the bank. Build this main in a separate class, not in your bank or bank account classes. To test your bank please run at least the following transactions:
- Create the bank.
- Create and add at least three named bank accounts to the bank, with initial balances.
- Look up an account and put money into it.
- Look up a different account and take money out of it.
- Look up an account and attempt an overdraft.
- Print an account summary before and after some of the above transactions.
What to turn in
Print out your source code along with an execution of the main from part three. Turn all this in at the beginning of class on 4 April.