java.lang.Object
stud.ntnu.idatt1005.pantrypal.models.Model
stud.ntnu.idatt1005.pantrypal.models.Recipe
This is an entity class representing a recipe.
It contains the name, groceries and steps of the recipe.
Goal: act as a model for a recipe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The recipe description of the recipe.private final String
The imagePath pointing to image location.private boolean
The boolean isFavorite, which is true if the recipe is a favorite, and false if it is not.private final GroceryRegister
The groceries needed for the recipe.private final StepRegister
The steps needed to make the recipe. -
Constructor Summary
ConstructorsConstructorDescriptionRecipe
(String name, String description, GroceryRegister recipeGroceries, StepRegister steps, String imagePath, boolean isFavorite) Constructor for the Recipe class. -
Method Summary
Modifier and TypeMethodDescriptionGet the description of the recipe.Get the image path of the recipe.boolean
Get the isFavorite boolean of the recipe.Get the groceries needed for the recipe.Get the steps needed to make the recipe.void
Toggle the isFavorite boolean to the opposite.private static boolean
validImagePath
(String imagePath) Check if the image path is valid.
-
Field Details
-
description
The recipe description of the recipe. -
recipeGroceries
The groceries needed for the recipe. -
steps
The steps needed to make the recipe. -
imagePath
The imagePath pointing to image location. -
isFavorite
private boolean isFavoriteThe boolean isFavorite, which is true if the recipe is a favorite, and false if it is not.
-
-
Constructor Details
-
Recipe
public Recipe(String name, String description, GroceryRegister recipeGroceries, StepRegister steps, String imagePath, boolean isFavorite) Constructor for the Recipe class.- Parameters:
name
- the name of the recipe.recipeGroceries
- the groceries needed for the recipe.steps
- the steps needed to make the recipe.
-
-
Method Details
-
validImagePath
Check if the image path is valid. By checking if the image path is a URL and then if the image path is correctly formatted. returns based on the result.- Parameters:
imagePath
- the image path to check.- Returns:
- true if the image path is valid, false if it is not.
-
getDescription
Get the description of the recipe.- Returns:
- the description of the recipe.
-
getRecipeGroceries
Get the groceries needed for the recipe.- Returns:
- the groceries needed for the recipe.
-
getRecipeSteps
Get the steps needed to make the recipe.- Returns:
- the steps needed to make the recipe.
-
getImagePath
Get the image path of the recipe.- Returns:
- the image path of the recipe.
-
getIsFavorite
public boolean getIsFavorite()Get the isFavorite boolean of the recipe.- Returns:
- the isFavorite boolean of the recipe.
-
toggleIsFavorite
public void toggleIsFavorite()Toggle the isFavorite boolean to the opposite. If isFavorite is true, it will be set to false, and if isFavorite is false, it will be set to true.
-