Class RecipeIngredient

java.lang.Object
no.ntnu.idatt1002.demo.data.recipes.Ingredient
no.ntnu.idatt1002.demo.data.recipes.RecipeIngredient

public class RecipeIngredient extends Ingredient
The RecipeIngredient class is an extension of the Ingredient class used as part of recipes that also stored the boolean value 'atHand'. This value can be set to true whenever the given ingredient, being part of a recipe, is also at hand to the user. Ingredients that the user has available are stored in the IngredientsAtHand class.
Author:
hannesofie
  • Constructor Details

    • RecipeIngredient

      public RecipeIngredient(FoodItem ingredient, double amount, MeasuringUnit unit)
      The constructor of a RecipeIngredient object inherits from the superclass Ingredient. The additional 'atHand' field is set to false ar default.
      Parameters:
      ingredient - What type of food the ingredient is.
      amount - The amount of the ingredient.
      unit - The unit of measure of the given amount of the ingredient.
  • Method Details

    • isAtHand

      public boolean isAtHand()
      The method returns the boolean value of the atHand field for the ingredient. If the ingredient being part of a recipe is also contained in the collection of ingredients at hand to the user, true is returned, if not, false is returned.
      Returns:
      True of the current recipe ingredient is available to the user.
    • setAtHand

      public void setAtHand(boolean atHand)
      The method sets the value of the atHand field for the ingredient to either true or false.
      Parameters:
      atHand - A boolean value to set the 'atHand' status of the ingredient.
    • toString

      public String toString()
      The method returns a String representation of a Recipe Ingredient object, listing its type, amount, unit and whether it is at hand or not.
      Overrides:
      toString in class Ingredient
      Returns:
      A String representation of the recipe ingredient object.