small changes
This commit is contained in:
@@ -208,6 +208,11 @@ public class Worm {
|
|||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param newOrientation
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static boolean isValidOrientation(double newOrientation) {
|
public static boolean isValidOrientation(double newOrientation) {
|
||||||
return newOrientation >= 0 && newOrientation < 2 * PI;
|
return newOrientation >= 0 && newOrientation < 2 * PI;
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ class WormTest {
|
|||||||
double angle = r.nextDouble() * 4 * Math.PI - 2 * Math.PI;
|
double angle = r.nextDouble() * 4 * Math.PI - 2 * Math.PI;
|
||||||
double oldAngle = worm.getOrientation();
|
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));
|
assertThrows(AssertionError.class, () -> worm.turn(angle));
|
||||||
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
|
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user