diff --git a/src/main/java/org/example/chaosgame/model/chaos/ChaosGame.java b/src/main/java/org/example/chaosgame/model/chaos/ChaosGame.java index 57867b0661fc7195ed709c839febc23bf3fe62ca..2b461a65f30263788a3ac0722029a25e753d4309 100644 --- a/src/main/java/org/example/chaosgame/model/chaos/ChaosGame.java +++ b/src/main/java/org/example/chaosgame/model/chaos/ChaosGame.java @@ -143,8 +143,9 @@ public class ChaosGame implements Subject { /** - * Method for running the chaos game. Randomly selects a transformation - * from the description and applies it to the current point. + * Method for running the chaos game. + * Selects which runSteps method to use based if it has a list of probabilities. + * Notifies observers after running the steps. */ public void runSteps() { if (description.getProbabilities() != null) { @@ -155,6 +156,10 @@ public class ChaosGame implements Subject { notifyObservers(); } + /** + * Method for running the chaos game. Randomly selects a transformation + * from the description and applies it to the current point. + */ private void runStepsUniform(int steps) { for (int i = 0; i < steps; i++) { int transformIndex = random.nextInt(description.getTransforms().size()); diff --git a/src/test/java/org/example/chaosgame/model/chaos/ChaosGameTest.java b/src/test/java/org/example/chaosgame/model/chaos/ChaosGameTest.java index 2b35732e5279f01bd215cbb2b23505b27a066de3..c6ec2d42aa21ab4c15519176e77f097c96097fef 100644 --- a/src/test/java/org/example/chaosgame/model/chaos/ChaosGameTest.java +++ b/src/test/java/org/example/chaosgame/model/chaos/ChaosGameTest.java @@ -42,6 +42,8 @@ class ChaosGameTest { @BeforeEach void init() { instance = ChaosGame.getInstance(juliaDescription, 500, 500); + instance.setSteps(0); + instance.setTotalSteps(0); } @Nested @@ -119,37 +121,23 @@ class ChaosGameTest { @Test void addTotalSteps() { instance.addTotalSteps(10); - assertEquals(10, instance.getTotalSteps(), "The total steps should be 10"); + instance.addTotalSteps(10); + assertEquals(20, instance.getTotalSteps(), "The total steps should be 10"); } - - @Test void resetTotalSteps() { instance.addTotalSteps(10); instance.resetTotalSteps(); assertEquals(0, instance.getTotalSteps(), "The total steps should be 0"); } - } - - @Test - void setSteps() { - } - - @Test - void setTotalSteps() { - } - @Test - void addTotalSteps() { - } - - @Test - void resetTotalSteps() { - } - - @Test - void runSteps() { + @Test + void runSteps() { + instance.setSteps(10); + instance.runSteps(); + assertEquals(10, instance.getSteps(), "The total steps should be 10"); + } } @Test @@ -159,4 +147,5 @@ class ChaosGameTest { @Test void setChaosCanvas() { } + } \ No newline at end of file