From 095514b0c4d852f1ccd02f85502bc14789c52f20 Mon Sep 17 00:00:00 2001
From: HSoreide <sofie.scisly@gmail.com>
Date: Mon, 13 Mar 2023 12:52:13 +0100
Subject: [PATCH] Write first draft of the RecipeRegister class

---
 .../demo/data/recipes/RecipeRegister.java     | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java

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 00000000..6e21ff7e
--- /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);
+
+    }
+}
-- 
GitLab