Closed book except you may talk with your Hw4 partner
BankAccount is a class like the one frequently used in lecture examples.
It has a constructor BankAccount(String owner, double initialDeposit), and
various methods (hopefully obvious, or remembered from lecture examples).
Given the following sequence of statements, draw a diagram to illustrate the state of things at the points indicated (1A and 1B). ArrayList baList; BankAccount mb1; String mName = "Marrttin"; mb1 = new BankAccount(mName, 12.13); md1.setName("Martin"); //1A. Draw a picture to illustrate the state of things // as of this point in the execution of the program //(continuation of program) baList = new ArrayList(); baList.add(mb1); BankAccount mb2 = new BankAccount("Alon", 350000.00); baList.add(mb2); //1B. Draw a new picture to illustrate the state of things // as of this point //Following statements are a continuation, but not part of the quiz // -- work on them if you have time baList.add(new BankAccount("BillG", 87000000000.0); BankAccount ba = (BankAccount) baList.get(1); ba.withdraw(10.0); // 1C. (OPTIONAL -- not needed for quiz credit) // Draw the picture as of this point. |
|
. | |
(2 pts.) Implement the following method, which searches an
ArrayList of BankAccount objects, and returns the total value of all the
balances. Use either size() or Iterator (you will impress your friends
more if you use Iterator!)
public double computeTotal(ArrayList accountList) {
|
|