java.lang.Object
stud.ntnu.idatt1005.pantrypal.registers.Register<Recipe>
stud.ntnu.idatt1005.pantrypal.registers.RecipeRegister

public class RecipeRegister extends Register<Recipe>
This is a register class for recipes. It contains a register of recipes structured in a hashmap. Goal: act as a register for recipes.
  • Constructor Details

    • RecipeRegister

      public RecipeRegister()
      Constructor for the RecipeRegister class. Initializes the recipe register.
  • Method Details

    • getErrorMessage

      protected String getErrorMessage()
      Returns an error message when a recipe does not exist in the register.
      Specified by:
      getErrorMessage in class Register<Recipe>
      Returns:
      a string error message.
    • getRecipe

      public Recipe getRecipe(String name) throws IllegalArgumentException
      Retrieves a recipe from the register by its name.
      Parameters:
      name - the name of the recipe to be retrieved.
      Returns:
      the recipe with the specified name.
      Throws:
      IllegalArgumentException - if the recipe does not exist in the register.
    • addRecipe

      public void addRecipe(Recipe recipe)
      Add a recipe to the recipe register.
      Parameters:
      recipe - the recipe to be added to the recipe register.
    • removeRecipe

      public void removeRecipe(Recipe recipe)
      Removes a recipe from the register.
      Parameters:
      recipe - the recipe to be removed from the register.
    • searchRecipes

      public List<Recipe> searchRecipes(String search)
      Searches for recipes in the register by name. And utilizes the Superclass' method from the Register class.
      Parameters:
      search - the search query.