Basic deposit and withdraw
Input
simulate_transactions(100, [('deposit', 50), ('withdraw', 30)])
Output
120
Start at 100, deposit 50 -> 150, withdraw 30 -> 120. All valid operations are recorded in TransactionHistory by the BankAccount.
Full lesson preview
Design a BankAccount class that uses composition: delegate transaction recording to a TransactionHistory class. Implement safe deposit/withdraw behavior and a helper to simulate scenarios.
Problem statement
Task
Examples
Input
simulate_transactions(100, [('deposit', 50), ('withdraw', 30)])
Output
120
Start at 100, deposit 50 -> 150, withdraw 30 -> 120. All valid operations are recorded in TransactionHistory by the BankAccount.
Input format
Output format
Constraints
Samples
Input
simulate_transactions(0, [('deposit', 10), ('deposit', 5), ('withdraw', 3)])
Output
12
0 + 10 + 5 - 3 = 12