Class IngredientsAtHand

java.lang.Object
no.ntnu.idatt1002.demo.data.recipes.IngredientsAtHand

public class IngredientsAtHand extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addIngredient(FoodItem ingredient)
    The method takes in an ingredient object and adds it to the collection of ingredients at hand.
    boolean
    atHand(FoodItem foodItem)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IngredientsAtHand

      public IngredientsAtHand()
  • Method Details

    • getIngredientsAtHand

      public List<FoodItem> 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

      public void addIngredient(FoodItem ingredient)
      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

      public boolean atHand(FoodItem foodItem)
      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

      public 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. 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.