From 23a6fcd4b98d7b45f96411eb7a1a38dcbe50586a Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Sun, 11 Mar 2018 20:03:04 +0100 Subject: [PATCH] small changes --- OGP1718-Worms/src/worms/model/Worm.java | 5 +++++ OGP1718-Worms/tests/worms/model/WormTest.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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); }