small changes

This commit is contained in:
2018-03-11 20:03:04 +01:00
parent 8e5e976c00
commit 23a6fcd4b9
2 changed files with 6 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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);
}