From b78d0c4e06f0c5b5b623950fcd46e40f99ff27d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5vard=20Daleng?=
 <142524365+MrMarHVD@users.noreply.github.com>
Date: Wed, 3 Apr 2024 12:44:24 +0200
Subject: [PATCH] Created template for ChaosGameTest and changed some
 formatting.

---
 .../java/edu/ntnu/stud/chaosgame/Main.java     |  2 +-
 .../controller/ChaosGameObserver.java          | 13 +++++++++++--
 .../stud/chaosgame/model/game/ChaosGame.java   |  9 ++++++---
 .../model/game/ChaosGameDescription.java       |  7 ++++++-
 .../stud/chaosgame/game/ChaosCanvasTest.java   |  5 ++++-
 .../stud/chaosgame/game/ChaosGameTest.java     | 18 ++++++++++++++++++
 6 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameTest.java

diff --git a/src/main/java/edu/ntnu/stud/chaosgame/Main.java b/src/main/java/edu/ntnu/stud/chaosgame/Main.java
index 6378a74..ed39dc0 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/Main.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/Main.java
@@ -29,7 +29,7 @@ public class Main {
       //ChaosGameDescription description = new ChaosGameFileHandler().readFromFile(path);
       //description = new ChaosGameDescription(minCoords, maxCoords, transforms);
       //description = new ChaosGameFileHandler().readFromFile(path);
-      description = factory.getDescriptions().get(1);
+      description = factory.getDescriptions().get(0);
       ChaosCanvas canvas = new ChaosCanvas(100, 100, description.getMinCoords(), description.getMaxCoords()); // Create canvas
       game = new ChaosGame(description, canvas);
 
diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java
index c0cb4a3..54c05bc 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java
@@ -12,7 +12,16 @@ public interface ChaosGameObserver {
 // TODO: Create interface
 
   /**
-   * Perform update
+   * Perform update of the ChaosCanvas.
+   *
+   * @param canvas the canvas.
    */
-  void update(ChaosGame game);
+  void updateCanvas(ChaosCanvas canvas);
+
+  /**
+   * Perform update of the ChaosGameDescription.
+   *
+   * @param description the description.
+   */
+  void updateDescription(ChaosGameDescription description);
 }
diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java
index 154a5e0..26352bf 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java
@@ -37,12 +37,13 @@ public class ChaosGame {
   private Random random;
 
   /**
-   * Number of transforms
+   * Number of transforms.
    */
   private int numOfTransforms;
 
   /**
    * Basic parameterised constructor.
+   *
    * @param description the ChaosGameDescription.
    * @param canvas the ChaosCanvas.
    */
@@ -55,7 +56,8 @@ public class ChaosGame {
   }
 
   /**
-   * Parameterised constructor with observers
+   * Parameterised constructor with observers.
+   *
    * @param description the ChaosGameDescription.
    * @param canvas the ChaosCanvas.
    * @param observers the ChaosGameObservers to be added.
@@ -71,6 +73,7 @@ public class ChaosGame {
 
   /**
    * Get the canvas of this chaos game.
+   *
    * @return the canvas.
    */
   public ChaosCanvas getCanvas() { return this.canvas; }
@@ -78,7 +81,7 @@ public class ChaosGame {
   /**
    * Run the chaos game for n iterations.
    *
-   * @param n the number of iterations
+   * @param n the number of iterations.
    */
   public void runSteps(int n) {
     for (int i = 0; i < n; i++) {
diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java
index 31034c6..f7c6ab8 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java
@@ -2,6 +2,7 @@ package edu.ntnu.stud.chaosgame.model.game;
 
 import edu.ntnu.stud.chaosgame.model.data.Vector2D;
 
+import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D;
 import edu.ntnu.stud.chaosgame.model.transformations.Transform2D;
 import java.util.List;
 
@@ -26,7 +27,8 @@ public class ChaosGameDescription {
   private final List<Transform2D> transforms;
 
     /**
-     * Constructor for ChaosGameDescription
+     * Constructor for ChaosGameDescription.
+     *
      * @param minCoords Inputs a {@link Vector2D} vector of lower left coordinates for the chaos game.
      * @param maxCoords Inputs a {@link Vector2D} vector of upper right coordinates for the chaos game.
      * @param transforms Inputs a list of transformations {@link AffineTransform2D} used in the chaos game.
@@ -42,6 +44,7 @@ public class ChaosGameDescription {
 
     /**
      * Getter method for transforms
+     *
      * @return Returns a list of transforms in the chaos game.
      */
     public List<Transform2D> getTransforms(){
@@ -50,6 +53,7 @@ public class ChaosGameDescription {
 
     /**
      * Getter method for minimum coordinates.
+     *
      * @return Returns a Vector2D containing the minimum coordinates.
      */
     public Vector2D getMinCoords(){
@@ -58,6 +62,7 @@ public class ChaosGameDescription {
 
     /**
      * Getter method for maximum coordinates.
+     *
      * @return Returns a Vector2D containing the maximum coordinates.
      */
     public Vector2D getMaxCoords(){
diff --git a/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosCanvasTest.java b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosCanvasTest.java
index 8211aec..a5c6152 100644
--- a/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosCanvasTest.java
+++ b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosCanvasTest.java
@@ -6,6 +6,9 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+/**
+ * Test for the ChaosCanvas {@link ChaosCanvas}.
+ */
 public class ChaosCanvasTest {
 
   private ChaosCanvas canvas;
@@ -14,7 +17,7 @@ public class ChaosCanvasTest {
    * Instantiate a canvas before each test
    */
   @BeforeEach
-  private void setUp() {
+  void setUp() {
     Vector2D minCoords = new Vector2D(0, 0);
     Vector2D maxCoords = new Vector2D(1, 1);
     this.canvas = new ChaosCanvas(100, 100, minCoords, maxCoords);
diff --git a/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameTest.java b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameTest.java
new file mode 100644
index 0000000..841a067
--- /dev/null
+++ b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameTest.java
@@ -0,0 +1,18 @@
+package edu.ntnu.stud.chaosgame.game;
+
+import edu.ntnu.stud.chaosgame.model.game.ChaosGame;
+import org.junit.jupiter.api.BeforeEach;
+
+/**
+ * Test for ChaosGame {@link ChaosGame}
+ */
+public class ChaosGameTest {
+
+  private ChaosGame game;
+
+  @BeforeEach
+  void setUp() {
+    //this.game = new ChaosGame()
+  }
+
+}
-- 
GitLab