added isValidOrientation
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user