Lab 12
More object oriented programming
In lab 11 we created some classes to deal with bank accounts. In this lab we will create a class called Bank that stores bank accounts.
Your Bank class should support the following methods:
add(account)- add the given account instance (can be either aCheckingAccountor aSavingsAccount).close(account_number)- close the account with the given numberpay_interest()- pay interest to allSavingsAccountinstances. How to tell if a given account is aSavingsAccount? One way is to check the name of the class usingaccount.__class__.__name__. Another is to simply check if the account instance has apay_interestmethod using thehasattrfunction. See http://docs.python.org/library/functions.html#hasattr A third option is to put a call to an account'spay_interestmethod in atry: except:block and ignore the exception if it happens.total_balance()- returns the total balance in all the bank's accounts.__len__()- returns the number of accounts in the bank
