#61MediumClasses· Classes and Inheritance
Class: Bank Account System
Input format
`operations`: the class name followed by method names. `arguments`: the argument list for each operation.
Output format
A list with the return value of each operation (`null` for the constructor).
Examples
Input: operations = ["BankAccount","deposit","withdraw","withdraw","get_balance","statement"], arguments = [["Ana",100],[500],[550],[100],[],[]]
Output: [null,true,true,false,-50,["deposit 500 -> 500","withdraw 550 -> -50"]]
After depositing 500 and withdrawing 550 the balance is -50, which the overdraft of 100 allows. Withdrawing 100 more would reach -150, so it is refused and not recorded.
Input: operations = ["SavingsAccount","deposit","add_interest","withdraw","statement"], arguments = [["Ben",5],[1000],[],[2000],[]]
Output: [null,true,1050,false,["deposit 1000 -> 1000","interest 50 -> 1050"]]
5% of 1000 is 50. A savings account has no overdraft, so withdrawing 2000 fails.
Constraints
- 1 <= len(operations) <= 100
- 0 <= overdraft_limit <= 10^6
- 0 <= rate_percent <= 100
- -10^6 <= amount <= 10^6
- #python
- #oop
- #classes
- #inheritance
