From 8aefb0c4921c675f6a29bef8f913ff5efc0879b2 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 12:15:15 +0100 Subject: [PATCH] commentaar points --- OGP1718-Worms/src/worms/model/Worm.java | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 2fcdac5..d8860f8 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -311,10 +311,29 @@ public class Worm { // region Points //=================================================================================== + /** + * Return the current action points of the worm + * the action points identifies the energy of the worm + */ public int getPoints() { return this.points; } + /** + * set the current points of the worm to the given points + * + * @param points + * the new points for the worm + * @post if the given points are bigger then the maximum points, the current points + * 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.maxPoints) + * | points = this.maxPoints + * |else if (points < 0) + * | points = 0 + * |this.points = points + */ public void setPoints(int points) { if (points > this.maxPoints) points = this.maxPoints; @@ -323,14 +342,40 @@ public class Worm { this.points = points; } + + /** + * set the maximum of points to the given maximum of points + * + * @param maxPoints + * 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) + * @post when the maximum points change, the current points should change too + * |setPoints(this.points) + */ private void setMaxPoints(double maxPoints) { this.maxPoints = (int) ceil(maxPoints); setPoints(this.points); } + + /** + * substract the current points of the 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) + */ private void subtractPoints (int value) { setPoints(this.points - value); } + + /** + * + * + * @param angle + */ private void subtractPoints (double angle) { setPoints(this.points - (int) ceil(toDegrees(angle) / 6));