From 7b738cb7e0620595ac6d6f398f5b94186726af8f Mon Sep 17 00:00:00 2001
From: Magnus Eik <“mageik@stud.ntnu.no”>
Date: Thu, 21 Mar 2024 13:47:25 +0100
Subject: [PATCH] Make ChaosGameDescription fields final and add validation.

---
 .../ntnu/stud/chaosgame/game/ChaosGameDescription.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java
index 4b55b0c..2d79156 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java
@@ -6,9 +6,9 @@ import edu.ntnu.stud.chaosgame.transformations.Transform2D;
 import java.util.List;
 
 public class ChaosGameDescription {
-    private Vector2D minCoords;
-    private Vector2D maxCoords;
-    private List<Transform2D> transforms;
+    private final Vector2D minCoords;
+    private final Vector2D maxCoords;
+    private final List<Transform2D> transforms;
 
     /**
      * Constructor for ChaosGameDescription
@@ -17,6 +17,9 @@ public class ChaosGameDescription {
      * @param transforms Inputs a list of transformations {@link Transform2D} used in the chaos game.
      */
     public ChaosGameDescription(Vector2D minCoords, Vector2D maxCoords, List<Transform2D> transforms) {
+        if (minCoords == null || maxCoords == null || transforms == null){
+            throw new IllegalArgumentException("Coordinates and transforms must not be null.");
+        }
         this.minCoords = minCoords;
         this.maxCoords = maxCoords;
         this.transforms = transforms;
-- 
GitLab