diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index a234d57..b6ef5ec 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -208,6 +208,11 @@ public class Worm { this.orientation = orientation; } + /** + * + * @param newOrientation + * @return + */ public static boolean isValidOrientation(double newOrientation) { return newOrientation >= 0 && newOrientation < 2 * PI; } diff --git a/OGP1718-Worms/tests/worms/model/WormTest.java b/OGP1718-Worms/tests/worms/model/WormTest.java index b422258..212e955 100644 --- a/OGP1718-Worms/tests/worms/model/WormTest.java +++ b/OGP1718-Worms/tests/worms/model/WormTest.java @@ -46,7 +46,7 @@ class WormTest { double angle = r.nextDouble() * 4 * Math.PI - 2 * Math.PI; double oldAngle = worm.getOrientation(); - if (0 > oldAngle + angle || 2 * Math.PI <= oldAngle + angle || worm.getActionPoints() - (long) Math.ceil(Math.toDegrees(angle) / 6) < 0) { + if (!Worm.isValidOrientation(oldAngle + angle) || worm.getActionPoints() - (long) Math.ceil(Math.toDegrees(angle) / 6) < 0) { assertThrows(AssertionError.class, () -> worm.turn(angle)); worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); }