Class ShoppingListController
java.lang.Object
edu.ntnu.stud.idatt1005.team3.controller.ShoppingListController
A class that generates a shopping list and alters it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIngredient
(String ingredientName, Double quantity, String unit) Adds an individual ingredient.void
addRecipeIngredients
(TheCookbookDB db, int recipeId) Adds ingredients from a chosen recipe to the shopping list.checkInventory
(TheCookbookDB db, List<FoodItem> shoppingList) Checks the shopping list against the inventory in the database.void
clear()
Generates the final shopping list.
-
Constructor Details
-
ShoppingListController
-
-
Method Details
-
addRecipeIngredients
Adds ingredients from a chosen recipe to the shopping list.- Parameters:
recipeId
- the id of the recipe you want to use.
-
addIngredient
Adds an individual ingredient.- Parameters:
ingredientName
- the ingredient you want to add.
-
generateShoppingList
Generates the final shopping list.- Returns:
- Returns the shopping list.
-
clear
public void clear() -
checkInventory
Checks the shopping list against the inventory in the database. Updates the inventory by removing if we have it, or adding to a final list what we are missing.- Parameters:
db
- the database.
-