diff --git a/src/Worm.java b/src/Worm.java index 9399672..df20aa2 100644 --- a/src/Worm.java +++ b/src/Worm.java @@ -1,3 +1,4 @@ +import be.kuleuven.cs.som.annotate.*; public class Worm { @@ -97,7 +98,7 @@ public class Worm { /** * @param orientation - * + * */ public void setOrientation(double orientation) { @@ -153,39 +154,39 @@ public class Worm { this.maxPoints = (int) Math.round(maxPoints); setPoints(this.points); } - + /** - * @param NumberSteps + * @param numberSteps ... * the number of steps the worm should take - * - * @post the new x-coordinate schould be the old one plus the number of steps multiplied + * + * @post the new x-coordinate schould be the old one plus the number of steps multiplied * with the distance of a step in the x-orientation * |new.CoordX = CoordX + NumberSteps * distanceX * @post the new y-coordinate schould be the old one plus the number of steps multiplied * with the distance of a step in the y-orientation * |new.CoordY = CoordY + NumberSteps * distanceY - * + * * @throws IllegalArgumentException - * when the total of steps is lower then 0 + * when the total of steps is lower then 0 * |NumberSteps < 0 */ public void move(int numberSteps) { if (numberSteps < 0) throw new IllegalArgumentException(); - + double distanceX = this.radius * Math.cos(this.orientation); double distanceY = this.radius * Math.sin(this.orientation); setCoordX(this.coordX + numberSteps * distanceX); setCoordY(this.coordY + numberSteps * distanceY); } - + /** * @param angleToAdd * the angle that must be added to the orientation - * + * * @pre the angle to add must be between 0 and 2pi (including 0) * |0 <= angleToAdd < 2pi - * + * * @post the new orientation is the old orientation plus the given angle * |new.orientation = orientation + angleToAdd * @post the resulting angle (= the new orientation) must be between 0 and 2pi (including 0)