Part 2 of 6 · 1 min read
Requirements
What the machine does, and what it must refuse.
Think of using a real machine. You put in coins, press a code, and either get a snack and change or a message. If you change your mind, you press a button for your coins back. The design must handle each of those, and the bad cases too.
Questions and the answers assumed here:
- What can a user do? Insert a coin, select a product by its code, or cancel.
- Which coins? Whole-rupee coins of 1, 2, 5 and 10 (made up).
- Can the machine run out of change? Yes. It has a limited stock of each coin.
- What if the user has put in too little? Say how much more is needed and keep the money.
- What if the chosen item is sold out? Say so and keep the money so that the user can choose again or cancel.
- Out of scope: card payments, refill by staff, and reports.
The numbered requirements:
- R1. A product has a code, a name, a price and a stock count.
- R2. Coins inserted add to the balance.
- R3. Selecting a product with enough balance and enough stock dispenses it and returns the change.
- R4. If change cannot be made from the coins in the machine, the sale is refused and nothing is lost.
- R5. Cancel returns exactly the coins that were inserted.
- R6. With no money inserted, selecting does nothing except tell the user to insert coins.
The nouns are machine, product, slot, coin, balance, stock and change. The verbs are insert, select, cancel, dispense and make change.
Check yourself: 1. What happens when the item is sold out? 2. Why must the machine track which coins were inserted? 3. Which requirement is about running out of change?