In this exercise, you will use generic collections to represent class associations in the Bank project domain model.
In your previous design, arrays were used to implement multiplicity in
the relationships between bank and customer, and between customers and
their accounts. This design has several significant limitations; the most
significant is that the array, after it is created, has a fixed size. The
Collections API was created to solve this and other limitations.
Figure 9-2 shows the domain model of the Bank project with the class
associations: a bank serves many customers, and a customer has many
accounts. Figure 9-2 also shows the detailed design for Bank and
customer classes that use a generic List to maintain these links.
Figure 9-1 Domain Model of the Bank Project with Details on the Bank and Customer Classes
Before you begin, make sure that you have changed directories to projects/BankingPrj/ using the cd command in the terminal window.
cd ~/projects/ BankingPrj/
Using a text editor, modify the Bank class source file in the src/can/mybank/domain/ directory. This class must satisfy the UML diagram in Figure 9 -2 on page Lab 9-11.
On the command line, use the javac command to compile the
test program.
On the command line, use the java command to run the test program. You should see the following output: Reading data file: ../data/teat.dat CUSTOMERS REPORT ================ Customer: Simms, Jane Savings Account: current balance is 500.0 Checking Account: current balance is 200.0 Customer: Bryant, Owen Checking Account: current balance is 200.0 Customer: Soley, Tim Savings Account: current balance is 1500.0 Checking Account: current balance is 200.0 Customer: Soley, Maria Savings Account: current balance is 150.0