commentaar move
This commit is contained in:
@@ -354,19 +354,31 @@ public class Worm {
|
||||
//===================================================================================
|
||||
|
||||
/**
|
||||
* @param numberSteps ...
|
||||
* move the worm for the given number of steps
|
||||
*
|
||||
* @param numberSteps
|
||||
* the number of steps the worm should take
|
||||
*
|
||||
* @post the new x-coordinate schould be the old one plus the number of steps multiplied
|
||||
* with the distance of a step in the x-orientation
|
||||
* |new.CoordX = CoordX + NumberSteps * distanceX
|
||||
* @post the new y-coordinate schould be the old one plus the number of steps multiplied
|
||||
* with the distance of a step in the y-orientation
|
||||
* |new.CoordY = CoordY + NumberSteps * distanceY
|
||||
*
|
||||
*
|
||||
* @post the x-coordinate of the new location of the worm schould be the location of
|
||||
* the old x-coordinate plus the number of steps multiplied with the distance
|
||||
* that the x-coordinate schould move (distance is equal to the radius multiplied
|
||||
* with the cosinus of the orientation)
|
||||
* |distanceX = this.radius * Math.cos(this.orientation)
|
||||
* |new.xCoordinate = this.location.item1 + numberSteps * distanceX
|
||||
* @post the y-coordinate of the new location of the worm schould be the location of
|
||||
* the old y-coordinate plus the number of steps multiplied with the distance
|
||||
* that the y-coordinate schould move (distance is equal to the radius multiplied
|
||||
* with the sinus of the orientation)
|
||||
* |distanceY = this.radius * Math.sin(this.orientation)
|
||||
* |new.yCoordinate = this.location.item2 + numberSteps * distanceY
|
||||
* @post the current value of action points has changed. The current value of action points
|
||||
* minus the cost of moving (abs(cos(theta)) + abs(4 sin(theta)))
|
||||
* |value = (int) Math.ceil(Math.abs(Math.cos(this.orientation)) + Math.abs(4 * Math.sin(this.orientation)))
|
||||
* |setPoints(this.points - value)
|
||||
* @throws IllegalArgumentException
|
||||
* when the total of steps is lower then 0
|
||||
* |NumberSteps < 0
|
||||
* when the total of steps is lower then 0 or when the cost of action point is more
|
||||
* then the current value of action point
|
||||
* |NumberSteps < 0 || cost > this.points
|
||||
*/
|
||||
public void move(int numberSteps) {
|
||||
if (numberSteps < 0)
|
||||
|
Reference in New Issue
Block a user