Preparing your design workspace

Loading the problem and your saved attempt…

Design a Cash Register with Inventory and Profit Tracking

Design a cash-register domain that records sales, updates inventory, and reports profit immediately.

Design a cash-register class system that manages inventory and tracks profit in real time.

For this exercise, assume each product has a unique SKU, unit sale price, unit cost, and nonnegative stock count; one sale may contain multiple SKU quantities; a sale succeeds atomically only when every requested quantity is available; and realized profit for a sold unit is its sale price minus its recorded unit cost.

Taxes, discounts, returns, supplier ordering, and payment-provider internals are out of scope. For this exercise, design the object model and contracts for stocking products, quoting a basket, completing a sale, and reading inventory and cumulative realized profit aggregated from completed sale margins.

Assume each checkout has a stable sale identifier so a retry returns the original receipt rather than applying inventory and profit twice. For the concurrency follow-up, assume multiple registers may sell the same SKU concurrently.