Skip to content
Snippets Groups Projects
Commit b78d0c4e authored by Håvard Daleng's avatar Håvard Daleng
Browse files

Created template for ChaosGameTest and changed some formatting.

parent 5bebf32b
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ public class Main { ...@@ -29,7 +29,7 @@ public class Main {
//ChaosGameDescription description = new ChaosGameFileHandler().readFromFile(path); //ChaosGameDescription description = new ChaosGameFileHandler().readFromFile(path);
//description = new ChaosGameDescription(minCoords, maxCoords, transforms); //description = new ChaosGameDescription(minCoords, maxCoords, transforms);
//description = new ChaosGameFileHandler().readFromFile(path); //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 ChaosCanvas canvas = new ChaosCanvas(100, 100, description.getMinCoords(), description.getMaxCoords()); // Create canvas
game = new ChaosGame(description, canvas); game = new ChaosGame(description, canvas);
......
...@@ -12,7 +12,16 @@ public interface ChaosGameObserver { ...@@ -12,7 +12,16 @@ public interface ChaosGameObserver {
// TODO: Create interface // 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);
} }
...@@ -37,12 +37,13 @@ public class ChaosGame { ...@@ -37,12 +37,13 @@ public class ChaosGame {
private Random random; private Random random;
/** /**
* Number of transforms * Number of transforms.
*/ */
private int numOfTransforms; private int numOfTransforms;
/** /**
* Basic parameterised constructor. * Basic parameterised constructor.
*
* @param description the ChaosGameDescription. * @param description the ChaosGameDescription.
* @param canvas the ChaosCanvas. * @param canvas the ChaosCanvas.
*/ */
...@@ -55,7 +56,8 @@ public class ChaosGame { ...@@ -55,7 +56,8 @@ public class ChaosGame {
} }
/** /**
* Parameterised constructor with observers * Parameterised constructor with observers.
*
* @param description the ChaosGameDescription. * @param description the ChaosGameDescription.
* @param canvas the ChaosCanvas. * @param canvas the ChaosCanvas.
* @param observers the ChaosGameObservers to be added. * @param observers the ChaosGameObservers to be added.
...@@ -71,6 +73,7 @@ public class ChaosGame { ...@@ -71,6 +73,7 @@ public class ChaosGame {
/** /**
* Get the canvas of this chaos game. * Get the canvas of this chaos game.
*
* @return the canvas. * @return the canvas.
*/ */
public ChaosCanvas getCanvas() { return this.canvas; } public ChaosCanvas getCanvas() { return this.canvas; }
...@@ -78,7 +81,7 @@ public class ChaosGame { ...@@ -78,7 +81,7 @@ public class ChaosGame {
/** /**
* Run the chaos game for n iterations. * Run the chaos game for n iterations.
* *
* @param n the number of iterations * @param n the number of iterations.
*/ */
public void runSteps(int n) { public void runSteps(int n) {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
......
...@@ -2,6 +2,7 @@ package edu.ntnu.stud.chaosgame.model.game; ...@@ -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.data.Vector2D;
import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D;
import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; import edu.ntnu.stud.chaosgame.model.transformations.Transform2D;
import java.util.List; import java.util.List;
...@@ -26,7 +27,8 @@ public class ChaosGameDescription { ...@@ -26,7 +27,8 @@ public class ChaosGameDescription {
private final List<Transform2D> transforms; 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 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 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. * @param transforms Inputs a list of transformations {@link AffineTransform2D} used in the chaos game.
...@@ -42,6 +44,7 @@ public class ChaosGameDescription { ...@@ -42,6 +44,7 @@ public class ChaosGameDescription {
/** /**
* Getter method for transforms * Getter method for transforms
*
* @return Returns a list of transforms in the chaos game. * @return Returns a list of transforms in the chaos game.
*/ */
public List<Transform2D> getTransforms(){ public List<Transform2D> getTransforms(){
...@@ -50,6 +53,7 @@ public class ChaosGameDescription { ...@@ -50,6 +53,7 @@ public class ChaosGameDescription {
/** /**
* Getter method for minimum coordinates. * Getter method for minimum coordinates.
*
* @return Returns a Vector2D containing the minimum coordinates. * @return Returns a Vector2D containing the minimum coordinates.
*/ */
public Vector2D getMinCoords(){ public Vector2D getMinCoords(){
...@@ -58,6 +62,7 @@ public class ChaosGameDescription { ...@@ -58,6 +62,7 @@ public class ChaosGameDescription {
/** /**
* Getter method for maximum coordinates. * Getter method for maximum coordinates.
*
* @return Returns a Vector2D containing the maximum coordinates. * @return Returns a Vector2D containing the maximum coordinates.
*/ */
public Vector2D getMaxCoords(){ public Vector2D getMaxCoords(){
......
...@@ -6,6 +6,9 @@ import org.junit.jupiter.api.Assertions; ...@@ -6,6 +6,9 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/**
* Test for the ChaosCanvas {@link ChaosCanvas}.
*/
public class ChaosCanvasTest { public class ChaosCanvasTest {
private ChaosCanvas canvas; private ChaosCanvas canvas;
...@@ -14,7 +17,7 @@ public class ChaosCanvasTest { ...@@ -14,7 +17,7 @@ public class ChaosCanvasTest {
* Instantiate a canvas before each test * Instantiate a canvas before each test
*/ */
@BeforeEach @BeforeEach
private void setUp() { void setUp() {
Vector2D minCoords = new Vector2D(0, 0); Vector2D minCoords = new Vector2D(0, 0);
Vector2D maxCoords = new Vector2D(1, 1); Vector2D maxCoords = new Vector2D(1, 1);
this.canvas = new ChaosCanvas(100, 100, minCoords, maxCoords); this.canvas = new ChaosCanvas(100, 100, minCoords, maxCoords);
......
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()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment