From 14603fa5ca0b31283675ec1065011d5c455c8252 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 10:51:07 +0100 Subject: [PATCH 1/5] commentaar variabelen --- OGP1718-Worms/src/worms/model/Worm.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index cb72c69..378eb35 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -27,7 +27,15 @@ public class Worm { // jumping private Tuple oldLocation; + + /** + * this variable contains the velocity of the jump of the worm + */ private double jumpVelocity; + + /** + * this variable contains the duration of the jump of the worm + */ private double jumpTime; /** From 42300e5b5c54895e47c079166c39835811862108 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 10:55:44 +0100 Subject: [PATCH 2/5] commentaar isValidLocation --- OGP1718-Worms/src/worms/model/Worm.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 378eb35..a2ff2de 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -160,6 +160,15 @@ public class Worm { this.location = location; } + /** + * check whether the given location is a valid location for the worm + * + * @param location + * the location to check + * @return True if and only if the location is not equal to null and the coordinates of + * the worm are numbers + * |result == (location != null) && (!Double.isNaN(location.item1)) && (!Double.isNaN(location.item2)) + */ private boolean isValidLocation(Tuplelocation) { return location != null && !Double.isNaN(location.item1) && !Double.isNaN(location.item2); } From b2aef5ff1979c04c72edae76c0e2b1fcec5b18d8 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 11:21:31 +0100 Subject: [PATCH 3/5] commentaar shape --- OGP1718-Worms/src/worms/model/Worm.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index a2ff2de..2fcdac5 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -243,6 +243,15 @@ public class Worm { setMass(radius); } + /** + * check whether the given radius is a valid radius for the worm + * + * @param radius + * the radius to check + * @return True if and only if the radius is bigger then the minimum radius + * (or equal) and the radius is a number + * |result == (radius >= this.minimumRadius && !Double.isNaN(radius)) + */ private boolean isValidRadius(double radius) { return radius >= this.minimumRadius && !Double.isNaN(radius); } @@ -256,6 +265,14 @@ public class Worm { return this.minimumRadius; } + /** + * check whether the given radius is a valid minimum radius for the worm + * + * @param radius + * the radius to check + * @return True if and only if the radius is a number and the radius is bigger then 0 + * |result == ((!Double.isNaN(radius)) && (radius > 0)) + */ private boolean isValidMinimumRadius(double radius) { return !Double.isNaN(radius) && radius > 0; } From 8aefb0c4921c675f6a29bef8f913ff5efc0879b2 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 12:15:15 +0100 Subject: [PATCH 4/5] 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)); From 2add5e583ad5e54c997b4d3a6e1dda2992b52854 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 8 Mar 2018 12:39:55 +0100 Subject: [PATCH 5/5] commentaar substractPoints(double angle) --- OGP1718-Worms/src/worms/model/Worm.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index d8860f8..06f7686 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -372,9 +372,13 @@ public class Worm { } /** - * + * substract the current points of the worm * * @param angle + * 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)) */ private void subtractPoints (double angle) {