Class IngredientsAtHand
java.lang.Object
no.ntnu.idatt1002.demo.data.recipes.IngredientsAtHand
The class holds a collection of FoodItem constants in an ArrayList that represents the groceries
that the user has available in real life. The class provides methods to add and remove food types
from the collection as well as checking if a given food type is available, i.e. is part of the
collection.
- Author:
- hannesofie
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIngredient
(FoodItem ingredient) The method takes in an ingredient object and adds it to the collection of ingredients at hand.boolean
The method takes in a constant of the FoodType enum class and checks if it is present in the collection.The method returns the collection of ingredients at hand as an arraylist of FoodItem enum constants.boolean
removeIngredient
(FoodItem ingredientType) The method takes in a value of the FoodItem enum as a parameter and removes it from the collection of ingredients at hand if it exists and returns true.
-
Constructor Details
-
IngredientsAtHand
public IngredientsAtHand()
-
-
Method Details
-
getIngredientsAtHand
The method returns the collection of ingredients at hand as an arraylist of FoodItem enum constants.- Returns:
- The collection of food types at hand to the user.
-
addIngredient
The method takes in an ingredient object and adds it to the collection of ingredients at hand.- Parameters:
ingredient
- The food type to add to the collection of ingredients at hand.
-
atHand
The method takes in a constant of the FoodType enum class and checks if it is present in the collection. If it is present, true is returned, otherwise false.- Parameters:
foodItem
- A constant value of the FoodItem enum class to check for in the collection of ingredients at hand.- Returns:
- True if the food type is at hand, otherwise false.
-
removeIngredient
The method takes in a value of the FoodItem enum as a parameter and removes it from the collection of ingredients at hand if it exists and returns true. If no ingredient of the given type was found in the collection, false is returned.- Parameters:
ingredientType
- What type of food to remove from the list of ingredients at hand.- Returns:
- True if the ingredient was found among the ingredients at hand and removed, false otherwise.
-