diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java new file mode 100644 index 0000000000000000000000000000000000000000..6e21ff7e10192f0f19d9cb216ad8577179541cfd --- /dev/null +++ b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java @@ -0,0 +1,22 @@ +package no.ntnu.idatt1002.demo.data.recipes; + +import java.util.ArrayList; +import java.util.List; + +public class RecipeRegister { + + private List<Recipe> recipes = new ArrayList<>(); + + + //TODO: Copy-constructor + + public void addRecipe (Recipe recipe) { + if(recipes.contains(recipe)) { + throw new IllegalArgumentException("The recipe already exists in the register."); // Or just replace? + } else if (recipe == null) { + throw new IllegalArgumentException("The recipe cannot be null."); + } + this.recipes.add(recipe); + + } +}