diff --git a/src/main/java/edu/ntnu/stud/chaosgame/Main.java b/src/main/java/edu/ntnu/stud/chaosgame/Main.java index 6378a7453e0f9c45c20dc5607c65037c5913ce3f..ed39dc003baef54df4b7d3f8c00ba1627e779bab 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 c0cb4a3ce11757f05ddf2dad40f6b73c74a32273..54c05bca66c3270dc206b48ce5f2c9126f1a1354 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 154a5e05fc6d50754b91e8e9c6a2c985e35002bf..26352bf9d4e5fd7843e2a489d312a87fe9985f0a 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 31034c675a018a57ec3db2168033b8153009cea0..f7c6ab889075c42b1a830df6bb8478ce08baf085 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 8211aec1ccf3b6c0b2637c5101d031ab4b3eee8e..a5c61525e31d8b4eb3aaf72988084b389957edb9 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 0000000000000000000000000000000000000000..841a0676cfb364516d347295d3962f2544e4ea00 --- /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() + } + +}