State Machine Diagram for Inventory class (Then Kim Yen) - smashita/CoffeeMaker-2019 GitHub Wiki
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; } }