From 2bcda45bb6ba9ab7bf84b3da497bc4a7f20b22b2 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Wed, 7 Mar 2018 19:59:52 +0100 Subject: [PATCH] commentaar move --- OGP1718-Worms/src/Worm.java | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/OGP1718-Worms/src/Worm.java b/OGP1718-Worms/src/Worm.java index 5696849..ef61c2a 100644 --- a/OGP1718-Worms/src/Worm.java +++ b/OGP1718-Worms/src/Worm.java @@ -354,19 +354,31 @@ public class Worm { //=================================================================================== /** - * @param numberSteps ... + * move the worm for the given number of steps + * + * @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 - * 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 - * + * + * @post the x-coordinate of the new location of the worm schould be the location of + * the old x-coordinate plus the number of steps multiplied with the distance + * that the x-coordinate schould move (distance is equal to the radius multiplied + * with the cosinus of the orientation) + * |distanceX = this.radius * Math.cos(this.orientation) + * |new.xCoordinate = this.location.item1 + numberSteps * distanceX + * @post the y-coordinate of the new location of the worm schould be the location of + * the old y-coordinate plus the number of steps multiplied with the distance + * that the y-coordinate schould move (distance is equal to the radius multiplied + * with the sinus of the orientation) + * |distanceY = this.radius * Math.sin(this.orientation) + * |new.yCoordinate = this.location.item2 + numberSteps * distanceY + * @post the current value of action points has changed. The current value of action points + * minus the cost of moving (abs(cos(theta)) + abs(4 sin(theta))) + * |value = (int) Math.ceil(Math.abs(Math.cos(this.orientation)) + Math.abs(4 * Math.sin(this.orientation))) + * |setPoints(this.points - value) * @throws IllegalArgumentException - * when the total of steps is lower then 0 - * |NumberSteps < 0 + * when the total of steps is lower then 0 or when the cost of action point is more + * then the current value of action point + * |NumberSteps < 0 || cost > this.points */ public void move(int numberSteps) { if (numberSteps < 0)