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
|
* @invar the orientation of the worm must be a valid location
|
||||||
* |isValidOrientation(getOrientation())
|
* |isValidOrientation(getOrientation())
|
||||||
* @invar the radius of the worm mus be a valid radius
|
* @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
|
* @invar the mass of the worm must be a valid mass
|
||||||
* |isValidMass(getMass())
|
* |isValidMass(getMass())
|
||||||
* @invar the value of the action points of the worm must be a valid value for action points
|
* @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);
|
setOrientation(orientation);
|
||||||
|
|
||||||
if (!isValidMinRadius(minRadius))
|
if (!isValidMinRadius(minRadius))
|
||||||
throw new IllegalArgumentException("Invalid min radius"); // TODO add decent exception msg
|
throw new IllegalArgumentException("Invalid min radius");
|
||||||
this.minRadius = minRadius;
|
this.minRadius = minRadius;
|
||||||
|
|
||||||
if (!canHaveAsRadius(radius))
|
if (!canHaveAsRadius(radius))
|
||||||
@@ -120,8 +120,6 @@ public class Worm {
|
|||||||
//===================================================================================
|
//===================================================================================
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// region location
|
// region location
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
|
|
||||||
@@ -206,11 +204,14 @@ public class Worm {
|
|||||||
* |new.getOrientation() == orientation
|
* |new.getOrientation() == orientation
|
||||||
*/
|
*/
|
||||||
private void setOrientation(double orientation) {
|
private void setOrientation(double orientation) {
|
||||||
// TODO nominal checking
|
assert isValidOrientation(orientation);
|
||||||
// TODO enkel 0 - 2pi toegelaten (isValidOrientation => invar)
|
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidOrientation(double newOrientation) {
|
||||||
|
return newOrientation >= 0 && newOrientation < 2 * PI;
|
||||||
|
}
|
||||||
|
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user