commentaar methodes ivm action points

This commit is contained in:
Leen Dereu
2018-03-11 16:14:28 +01:00
parent a361b4abba
commit 40e6a88c10
2 changed files with 23 additions and 17 deletions

View File

@@ -294,8 +294,6 @@ public class Worm {
return radius >= getMinRadius() && !Double.isNaN(radius); return radius >= getMinRadius() && !Double.isNaN(radius);
} }
/** /**
* Return the mass of the worm * Return the mass of the worm
* the mass of the worm expresses the weight 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 this.actionPoints;
} }
/**
* Return the maximum of action points of the worm
* the maximum action points identifies the maximum energy of the worm
*/
@Basic @Basic
public long getMaxActionPoints() { public long getMaxActionPoints() {
return this.maxActionPoints; return this.maxActionPoints;
@@ -358,11 +360,11 @@ public class Worm {
* are equal to the maximum points. If the given points are lower then 0 * 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 * 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 * maximum points and 0, the current points is equal to the given points
* |if (points > this.maxActionPoints) * |if (actionPoints > getMaxActionPoints())
* | actionPoints = this.maxActionPoints * | actionPoints = getMaxActionPoints();
* |else if (actionPoints < 0) * |else if (actionPoints < 0)
* | actionPoints = 0 * | actionPoints = 0;
* |this.actionPoints = actionPoints * |this.actionPoints = actionPoints;
*/ */
public void setActionPoints(long actionPoints) { public void setActionPoints(long actionPoints) {
if (actionPoints > getMaxActionPoints()) if (actionPoints > getMaxActionPoints())
@@ -374,8 +376,12 @@ public class Worm {
} }
/** /**
*substract the current points of the worm
* *
* @param delta ... * @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) { 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; 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; private long maxActionPoints;
@@ -398,9 +404,9 @@ public class Worm {
* @param maxActionPoints * @param maxActionPoints
* the new maximum of points for the worm * the new maximum of points for the worm
* @post the new maximum points is set to the given maximum points (as an integer) * @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 * @post when the maximum points change, the current points should change too
* |setPoints(this.points) * |setActionPoints(getActionPoints)
*/ */
private void setMaxActionPoints(double maxActionPoints) { private void setMaxActionPoints(double maxActionPoints) {
this.maxActionPoints = round(maxActionPoints); this.maxActionPoints = round(maxActionPoints);
@@ -413,7 +419,7 @@ public class Worm {
* @param value * @param value
* the value which should be substracted * the value which should be substracted
* @post the current points are set to the old current points minus the given value * @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) { private void subtractActionPoints (long value) {
@@ -427,7 +433,7 @@ public class Worm {
* the angle needed to calculate the new current points * the angle needed to calculate the new current points
* @post the current points are set to the old current points minus * @post the current points are set to the old current points minus
* the angle (in degrees) divided by 6 * 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) { private void subtractActionPoints (double angle) {

View File

@@ -1,8 +1,8 @@
* zorgen dat @invar klopt in de code * zorgen dat @invar klopt in de code
* documentatie: - Worm DONE * documentatie: - Worm DONE
- Worm DONE - Worm DONE
- getMaxActionPoints - getMaxActionPoints DONE
- decreaseActionPoints - decreaseActionPoints DONE
- canTurn - canTurn
- Tuple (methode) - Tuple (methode)
* testen schrijven * testen schrijven