Class RecipeRegister
java.lang.Object
stud.ntnu.idatt1005.pantrypal.registers.Register<Recipe>
stud.ntnu.idatt1005.pantrypal.registers.RecipeRegister
This is a register class for recipes.
It contains a register of recipes structured in a hashmap.
Goal: act as a register for recipes.
-
Field Summary
Fields inherited from class stud.ntnu.idatt1005.pantrypal.registers.Register
registerMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a recipe to the recipe register.protected String
Returns an error message when a recipe does not exist in the register.Retrieves a recipe from the register by its name.void
removeRecipe
(Recipe recipe) Removes a recipe from the register.searchRecipes
(String search) Searches for recipes in the register by name.Methods inherited from class stud.ntnu.idatt1005.pantrypal.registers.Register
addModel, containsModel, getModel, getRegister, removeModel, searchModels
-
Constructor Details
-
RecipeRegister
public RecipeRegister()Constructor for the RecipeRegister class. Initializes the recipe register.
-
-
Method Details
-
getErrorMessage
Returns an error message when a recipe does not exist in the register.- Specified by:
getErrorMessage
in classRegister<Recipe>
- Returns:
- a string error message.
-
getRecipe
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
Add a recipe to the recipe register.- Parameters:
recipe
- the recipe to be added to the recipe register.
-
removeRecipe
Removes a recipe from the register.- Parameters:
recipe
- the recipe to be removed from the register.
-
searchRecipes
Searches for recipes in the register by name. And utilizes the Superclass' method from the Register class.- Parameters:
search
- the search query.
-