Bank Account

Level: Intermediate 30–60 min

Concepts: StateValidationEdge CasesBoundaries

Solutions: C# | TypeScript | Python


Create a bank account that tracks transactions and enforces business rules.

Requirements

  1. Open Account — create an account with an initial balance of 0
  2. Deposit — add funds to the account
    • Amount must be positive
    • Records the transaction with date and amount
  3. Withdraw — remove funds from the account
    • Amount must be positive
    • Cannot withdraw more than current balance (no overdraft)
    • Records the transaction with date and amount
  4. Get Balance — returns the current balance
  5. Print Statement — returns a formatted statement showing all transactions

Statement format:

Date       | Amount  | Balance
2026-01-15 |  500.00 |  500.00
2026-01-20 | -100.00 |  400.00
2026-01-25 |  200.00 |  600.00

Transactions are printed in chronological order with running balance.

Test Cases

ActionAmountExpected BalanceNotes
Deposit500500
Deposit200700
Withdraw100600
Withdraw700600Rejected — insufficient funds
Deposit-50600Rejected — negative amount
Withdraw-50600Rejected — negative amount
Deposit0600Rejected — zero amount

Bonus

  • Add transfer between two accounts — atomic operation, both sides must succeed
  • Add overdraft limit — allow withdrawals up to a configurable negative balance
  • Add interest calculation — apply monthly interest based on average daily balance
  • Add transaction categories — tag transactions and filter statements by category

Reference Walkthrough

Full C#, TypeScript, and Python implementations live at tddbuddy-reference-katas/bank-account with the same twenty scenarios across all three languages, a fluent AccountBuilder, and a Clock collaborator so tests don’t depend on real time.

Unlike Gilded Rose (which ships in low gear, one commit per scenario), Bank Account ships in middle gear — a single commit per language with the full domain design. See the repo’s Gears section for why that’s a deliberate teaching choice.