From 916342be71603adda773a6033e7a84bfb72c11ab Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Sun, 11 Mar 2018 21:25:36 +0100 Subject: [PATCH] aanpassen commentaar --- OGP1718-Worms/src/worms/model/Worm.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 7feec97..55c7db8 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -657,13 +657,13 @@ public class Worm { * * @post the worm jumps to his new place. The new place is the x-coordinate plus the jump distance * with the jump velocity - * |worms.util.Tuple.create(location.item1 + jumpDistance(this.jumpVelocity), location.item2) + * |setLocation(Tuple.create(getLocation().item1 + jumpDistance(this.jumpVelocity()), getLocation().item2)) * @post the current action actionPoints schould be 0 after a jump - * |this.actionPoints = 0 + * |setActionPoints(0) * @throws IllegalStateException * if the current action actionPoints is equal to 0 or the orientation is more then * pi the worm can not jump - * |this.actionPoints == 0 || this.orientation < Math.PI + * |!canJump() */ public void jump() throws IllegalStateException { @@ -680,6 +680,9 @@ public class Worm { * @return the time the worm will jump. The distance divided by the velocity multiplied * with the cosinus of the orientation * |jumpDistance(this.jumpVelocity) / (this.jumpVelocity * Math.cos(this.orientation)) + * @throws IllegalStateException + * Orientation is bigger then pi or action points is equal to 0 + * |getOrientation() >= PI || getActionPoints() == 0 */ public double jumpTime() { @@ -716,7 +719,7 @@ public class Worm { * * @return True if and only if the action actionPoints is bigger then 0 and the orientation * is lower then pi - * |result == this.actionPoints > 0 && this.orientation < Math.PI + * |result == getActionPoints() > 0 && getOrientation() < PI */ private boolean canJump() { return getActionPoints() > 0 && getOrientation() < PI; @@ -729,7 +732,7 @@ public class Worm { * The velocity of the jump * @return The distance the worm will jump. The distance is equal to the velocity powered by 2 multiplied * with the sinus of 2 times the orientation en this divided with the gravity - * |(Math.pow(v, 2) * Math.sin(2 * this.orientation)) / this.G + * |(pow(v, 2) * sin(2 * getOrientation())) / G */ private double jumpDistance(double v) { return (pow(v, 2) * sin(2 * getOrientation())) / G; @@ -741,8 +744,8 @@ public class Worm { * @return the velocity of the jump. The force of the jump is equal to 5 multiplied with the * current action actionPoints plus the mass multiplied with the gravity. Therefrom the velocity * is equal to the force divided with the mass, multiplied with the time te force takes - * |force = 5 * this.actionPoints + this.mass * G - * |velocity = (force / this.mass) * FORCE_TIME + * |force = 5 * getActionPoints() + getMass() * G + * |velocity = (force / getMass()) * FORCE_TIME */ private double jumpVelocity() {