-
Notifications
You must be signed in to change notification settings - Fork 10
State Machine Diagram for Inventory class (Then Kim Yen)
ThenKimYen edited this page Dec 7, 2019
·
1 revision
The above diagram is state machine diagram for inventory class. At the initial state, all inventory is assigned to a quantity of 15, which puts them in fill state. Whenever one of the inventory becomes 0, it becomes a half-empty state. It will enter the empty state when all inventory becomes 0. The below code is used to execute calculation to check the ingredient.
public synchronized boolean useIngredients(Recipe r) { if (this.enoughIngredients(r)) { coffee += r.getAmtCoffee(); milk -= r.getAmtMilk(); sugar -= r.getAmtSugar(); chocolate -= r.getAmtChocolate(); return true; } else { return false; } }