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

Write first draft of the class IngredientsAtHand

parent c1c64104
No related branches found
No related tags found
1 merge request!7Create food and recipe classes with tests
package no.ntnu.idatt1002.demo.data.recipes;
import java.util.List;
public class IngredientsAtHand {
private List<Ingredient> ingredientsAtHand;
public List<Ingredient> getIngredientsAtHand() {
return ingredientsAtHand;
}
public void setIngredientsAtHand(List<Ingredient> ingredientsAtHand) {
this.ingredientsAtHand = ingredientsAtHand;
}
public void addIngredient(Ingredient ingredient) {
this.ingredientsAtHand.add(ingredient);
}
/**
* Returns null if no ingredient of the requested type is found in the collection.
* @param ingredientType
* @return
*/
public Ingredient getIngredient(FoodItem ingredientType) {
return this.getIngredientsAtHand().stream()
.filter((ingredient) -> ingredient.getFoodType() == ingredientType)
.findFirst().orElse(null);
}
}
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