Question: The str method of the Bank class returns a string containing the accounts in random order. Design and implement a change that causes the accounts

The str method of the Bank class returns a string containing the accounts in random order. Design and implement a change that causes the accounts to be placed in the string by order of name. (Hint: You will also have to define some methods in the SavingsAccount class.)

(I think this is the Bank class below)

Bank METHOD WHAT IT DOES
b = Bank() Returns a bank.
b.add(account) Adds the given account to the bank.
b.remove(pin) Removes the account with the given pin from the bank and returns the account. If the pin is not in the bank, returns None.
b.get(pin) Returns the account associated with the pin if the PIN is in the bank. Otherwise, returns None.
b.computeInterest() Computes the interest on each account, deposits it in that account, and returns the total interest.
__str__(b) Same as str(b). Returns a string representation of the bank (all the accounts).

(saving account methods below)

SavingsAccount METHOD WHAT IT DOES
a = SavingsAccount(name, pin, balance = 0.0) Returns a new account with the given name, PIN, and balance.
a.deposit(amount) Deposits the given amount to the accounts balance.
a.withdraw(amount) Withdraws the given amount from the accounts balance.
a.getBalance() Returns the accounts balance.
a.getName() Returns the accounts name.
a.getPin() Returns the accounts PIN.
a.computeInterest() Computes the accounts interest and deposits it.
__str__(a) Same as str(a). Returns the string representation of the account.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!