commentaar points
This commit is contained in:
@@ -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));
|
||||
|
Reference in New Issue
Block a user