Skip to content
Snippets Groups Projects
Commit 3e3112ec authored by HSoreide's avatar HSoreide
Browse files

Make updateIngredientStatus of Recipe class provide number of missing ingredients

parent 8a69ecac
No related branches found
No related tags found
2 merge requests!42Hs frontend recipes,!41Hs frontend recipes
......@@ -13,6 +13,7 @@ public class Recipe {
private String name = "";
private List<RecipeIngredient> ingredientList = new ArrayList<>();
private String instructions = "";
private int missingIngredients;
public Recipe(String name, String description ) {
if(name.isBlank() | description.isBlank()) {
......@@ -94,16 +95,21 @@ public class Recipe {
} else if (ingredientsAtHand.getIngredientsAtHand().size() < 1) {
throw new IllegalArgumentException("The collection of ingredients at hand is empty.");
} else {
missingIngredients = 0;
ingredientList.forEach((inRecipe) -> {
ingredientsAtHand.getIngredientsAtHand().forEach((atHand) -> {
if(inRecipe.getFoodType() == atHand.getFoodType()) {
inRecipe.setAtHand(true);
} else {
missingIngredients += 1;
}
});
});
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment