Documentatie nieuwe methodes

This commit is contained in:
Leen Dereu
2018-04-08 14:30:41 +02:00
parent 81d3b31213
commit 6d56d86e74

View File

@@ -86,6 +86,7 @@ public class Worm extends GameObject {
* |new.getRadius() == radius
* @post the new minimum radius of the worm is equal to the given minimum radius
* |new.getMinRadius() == minRadius
* @post actionpoints en hitpoints
* @throws IllegalArgumentException
* the given location is not a valid location for a worm
* |!isValidLocation(location)
@@ -521,6 +522,10 @@ public class Worm extends GameObject {
subtractActionPoints(cost);
}
/**
*
* @return
*/
public Coordinate getFurthestLocationInDirection() {
return null;
}
@@ -737,11 +742,27 @@ public class Worm extends GameObject {
// region hitPoints
//===================================================================================
/**
* Return the current hit points of the worm
* the hit points identifies the strength of the worm
*/
@Basic @Raw
public long getHitPoints() {
return this.hitPoints;
}
/**
* set the current hit points of the worm to the given points
*
* @param hitPoints
* the new points for the worm
* @post if the given points are equal or lower then zero, the worm should be dead.
* Otherwise the current hit points are set to the given points.
* |if (hitpoints <= 0)
* | terminate();
* |else
* | new.getHitPoints() == hitpoints
*/
@Raw
private void setHitPoints(long hitPoints) {
if (hitPoints <= 0)
@@ -749,8 +770,19 @@ public class Worm extends GameObject {
this.hitPoints = hitPoints;
}
/**
* this variable contains the current hitpoints of the worm
*/
private long hitPoints;
/**
* increment the hit points with the given value
*
* @param value
* the value that should be substracted
* @post the current hit points should be substracted with the given value.
* |new.getHitPoints() == old.getHitPoints() - value
*/
public void incrementHitPoints(long value) {
setHitPoints(getHitPoints() - value);
}