Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement Bank Accounts and Transfers

Model bank accounts and implement safe in-memory transfers, then add an account kind without rewriting the core.

For this exercise, assume a small in-memory bank processes one command at a time. A client can open an account with a unique ID and zero balance, inspect its balance, deposit or withdraw positive integer-cent amounts, and transfer a positive amount between two existing accounts. Balances may not become negative.

A transfer changes both balances or neither; an unknown account, duplicate ID, non-positive amount, insufficient funds, or self-transfer returns a named failure without changing either balance. Arithmetic does not overflow for the supplied inputs.

Design the objects, contracts and interactions, then implement transfer and demonstrate its success and failure tests. As a follow-up, add a second account kind with a different withdrawal rule.

State a simple rule you assume for that discussion; it applies only to withdraw and must not change transfer or the original kind. Concurrent commands, durable storage, transaction history, request retries, interest, fees, authentication, external settlement, and user interfaces are outside scope.