A coin-operated drink dispenser where all three drink choices share one parameterized hasEnoughBalance guard.
Try this: insert coins and watch snapshot.can() automatically enable each drink button and SVG transition arrow as your balance crosses $1.50, $2.00, and $2.50.
Drink Dispenser
Buttons auto-enable via snapshot.can()
Inserted Credit
Insert coins to begin
$0.00
☕
Espresso
$1.50
🍵
Matcha
$2.00
🧊
Cold Brew
$2.50
Pickup Tray Empty
Stateidle
Balance$0.00
Served0
Last ItemNone
Insert Coins
Select Drink (Parameterized Guard)
What's happening: Insert coins to increase context.balance. All three drink transitions share a single hasEnoughBalance guard configured with different params: { price } values!
Statechart
Click any highlighted transition arrow in the diagram to trigger it.