From 40e6a88c109b9ca86d6bfbf1622612054f116e43 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Sun, 11 Mar 2018 16:14:28 +0100 Subject: [PATCH] commentaar methodes ivm action points --- OGP1718-Worms/src/worms/model/Worm.java | 36 ++++++++++++++----------- docs/TODO.txt | 4 +-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 7466eed..6444fb5 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -294,8 +294,6 @@ public class Worm { return radius >= getMinRadius() && !Double.isNaN(radius); } - - /** * Return the mass of the worm * the mass of the worm expresses the weight of the worm @@ -344,6 +342,10 @@ public class Worm { return this.actionPoints; } + /** + * Return the maximum of action points of the worm + * the maximum action points identifies the maximum energy of the worm + */ @Basic public long getMaxActionPoints() { return this.maxActionPoints; @@ -358,11 +360,11 @@ public class Worm { * are equal to the maximum points. If the given points are lower then 0 * the current points are equal to 0. If the given points is between the * maximum points and 0, the current points is equal to the given points - * |if (points > this.maxActionPoints) - * | actionPoints = this.maxActionPoints - * |else if (actionPoints < 0) - * | actionPoints = 0 - * |this.actionPoints = actionPoints + * |if (actionPoints > getMaxActionPoints()) + * | actionPoints = getMaxActionPoints(); + * |else if (actionPoints < 0) + * | actionPoints = 0; + * |this.actionPoints = actionPoints; */ public void setActionPoints(long actionPoints) { if (actionPoints > getMaxActionPoints()) @@ -374,8 +376,12 @@ public class Worm { } /** - * - * @param delta ... + *substract the current points of the worm + * + * @param delta + * the value which should be decreased + * @post the current points are set to the old current points minus the given value + * |setActionPoints(getActionPoints() - delta) */ public void decreaseActionPoints (long delta) { @@ -383,12 +389,12 @@ public class Worm { } /** - * this variable contains the current action actionPoints of the worm + * this variable contains the current action points of the worm */ private long actionPoints; /** - * this variable contains the maximum actionPoints a worm can have + * this variable contains the maximum action points a worm can have */ private long maxActionPoints; @@ -398,9 +404,9 @@ public class Worm { * @param maxActionPoints * the new maximum of points for the worm * @post the new maximum points is set to the given maximum points (as an integer) - * |this.maxPoints = (int) ceil(maxPoints) + * |this.maxPoints = round(maxActionPoints) * @post when the maximum points change, the current points should change too - * |setPoints(this.points) + * |setActionPoints(getActionPoints) */ private void setMaxActionPoints(double maxActionPoints) { this.maxActionPoints = round(maxActionPoints); @@ -413,7 +419,7 @@ public class Worm { * @param value * the value which should be substracted * @post the current points are set to the old current points minus the given value - * |setPoints(this.points - value) + * |setActionPoints(getActionPoints() - value) */ private void subtractActionPoints (long value) { @@ -427,7 +433,7 @@ public class Worm { * the angle needed to calculate the new current points * @post the current points are set to the old current points minus * the angle (in degrees) divided by 6 - * |setPoints(this.points - (int) ceil(toDegrees(angle) / 6)) + * |setActionPoints(getActionPoints() - (long) ceil(toDegrees(angle) / 6)) */ private void subtractActionPoints (double angle) { diff --git a/docs/TODO.txt b/docs/TODO.txt index 8e1f98c..cf33b9c 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -1,8 +1,8 @@ * zorgen dat @invar klopt in de code * documentatie: - Worm DONE - Worm DONE - - getMaxActionPoints - - decreaseActionPoints + - getMaxActionPoints DONE + - decreaseActionPoints DONE - canTurn - Tuple (methode) * testen schrijven