Objective
A bank with classes (Account and Bank) and its own exception hierarchy: each possible error is a subclass of a base error, and the main program catches them all with a single except.
Instructions
- The first line has the number
nof commands:open name,deposit name amount,withdraw name amount,transfer source target amountorbalance name. Amounts are integers. - Each successful command shows
OK, exceptbalance, which showsname: balance. Errors showError: messagewith:account not found,duplicate account,invalid amount(zero or negative amount) orinsufficient balance. - A failed transfer must not change any balance. Check first that both accounts exist.
5
open ana
deposit ana 100
withdraw ana 30
balance ana
withdraw ana 500
OK
OK
OK
ana: 70
Error: insufficient balance
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise