From 8e5e976c00bc312cfbf79c8d1a0dd06f81c2dc9c Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Sun, 11 Mar 2018 19:58:10 +0100 Subject: [PATCH] added isValidOrientation --- OGP1718-Worms/src/worms/model/Worm.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 88bb050..a234d57 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -14,7 +14,7 @@ import static java.lang.Math.*; * @invar the orientation of the worm must be a valid location * |isValidOrientation(getOrientation()) * @invar the radius of the worm mus be a valid radius - * |isValidMinRadis(getRadius()) + * |isValidMinRadius(getRadius()) * @invar the mass of the worm must be a valid mass * |isValidMass(getMass()) * @invar the value of the action points of the worm must be a valid value for action points @@ -101,7 +101,7 @@ public class Worm { setOrientation(orientation); if (!isValidMinRadius(minRadius)) - throw new IllegalArgumentException("Invalid min radius"); // TODO add decent exception msg + throw new IllegalArgumentException("Invalid min radius"); this.minRadius = minRadius; if (!canHaveAsRadius(radius)) @@ -120,8 +120,6 @@ public class Worm { //=================================================================================== // endregion - - // region location //=================================================================================== @@ -206,11 +204,14 @@ public class Worm { * |new.getOrientation() == orientation */ private void setOrientation(double orientation) { - // TODO nominal checking - // TODO enkel 0 - 2pi toegelaten (isValidOrientation => invar) + assert isValidOrientation(orientation); this.orientation = orientation; } + public static boolean isValidOrientation(double newOrientation) { + return newOrientation >= 0 && newOrientation < 2 * PI; + } + //=================================================================================== // endregion