Comp 102 Project 2
Summary and goals:
In this project you will have the opportunity to further use
arrayList's since many of you thought that you were still a little wary
of them. You will also use UML to help develope your project more
readily.
Details:
Write a program with three classes as seen in the UML diagram below.
This program will simulate a very simple bank program with accounts.
Your program will read in data from the user, and insert each new
BankAccount object into the ArrayList so that the Bank Accounts are all
in Alphabetical order (you'll need some sort of loop and use the
version of the add method from the ArrayList class which allows you to choose where the item will be added/inserted.
Program behavior:
Your program should read in data for bank accounts. Read as many as the
user wants to add. When the user is done, calculate the largest account
Balance, print it, and then print out each bank account with the
account holder's name, the account number, and the balance.
This time you will implement my design rather than making your own design up. You'll find my design in the UML diagram below.
Your implementation therefore needs to have three classes (the
ArrayList class is from the java library of course). Each of the
methods that you need to implement are explained a bit more below. You
may of course add any other methods that you want ot need to finish the
project.
- BankAccount Class: This is an immutable class. All BankAccount object are not changed after being created.
- getName: this should be an accessor for the Name instance variable
- getBalance: this should be an accessor for the balance instance variable
- getAcctNum: This should be an accessor for the accountNumber instance variable
- BankAccount: This constructor takes three parameters, You should use the parameters to initialize each instance variable.
- Bank:
- Bank: This constructor should create the ArrayList which is held in the accounts instance variable
- printAccounts should print out all accounts in order from start to end.
- getMaxBalance: this method returns the maximum balance of all BankAccounts in the accounts instance variable
- addAccount takes a BankAccount object and inserts it into the
correct place in account based on the Name instance variable of the new
Account.
- BankTester
- Main: this is the classic main method. It should create the
Bank object and either call methods to read in data from the user (in
which case you need to make those methods on your own) oryou can loop and read in data yourself.
Readme:
You also need to have a readme.txt file in your folder which contains
- your name
- a brief (one paragraph) description of how
you implemented the project, in particular, how did you decide to keep
everything ordered?
- anything that is left undone in the project.
Submission:
As before, you need to submit using csdev01:
from the command line on csdev01, use the following line to move into
my directory
cd /home/bscstaff/jsantore/onlineSubmit
then use this line to run the submit program:
./submit.sh &