Prototype: BalanceAccount starts at zero; positive deposits return balance, positive withdrawals return false if unaffordable, otherwise debit once and return true. Invalid amounts raise unchanged.

Final: Bank has createAccount, nullable balance, and deposit (validate positive amount before missing-account result). transfer(requestId,source,target,amount) validates positive amount first; exact successful retry returns its original TransferResult, conflicting successful ID raises. Missing/same accounts or insufficient funds return null; failures reserve no ID. Success moves money and adds amount only to source outgoing. topSpenders(limit) includes zero spenders, ordered outgoing descending then ID; negative limit raises, zero gives empty.

The complete public API is in Exercise.java. All domain classes are public static nested classes of Exercise; construct them as new Exercise.ClassName(...). Do not implement a solution in the test runner. Each instance owns independent state. Unless explicitly allowed, null inputs are outside the domain. Failed operations leave state unchanged; validation happens before mutation.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.