For the ADT Bank, include operations for adding a new account to its array of accounts, depositing an amount to a given account (according to its id number), and withdrawing an amount from a given account (according to its id number). Given an account id number, the search method should return the account (in the array accounts) that has that id number. The constructor takes in a string representing the name of the bank, allocates storage for the array (each element of which is a reference to an Account object), and initializes the number of accounts to 0.
Reuse, when possible, methods of the ADT Account as well as methods of the ADT Bank. For example, the deposit and withdraw methods of the ADT Bank can use the search method of ADT Bank as a helper method to first find the account to update within the array of accounts; once the account is found, it can then be updated via a call to the deposit or withdraw method of the ADT Account.
Bank |
- nameOfBank : String - accounts : Account[] - numOfAccounts : int |
+ Bank (String) + addAccount (Account) + search (String) : Account // assuming id is a String; see description above. + deposit (String, Money) + withdraw (String, Money) + toString() : String |