small changes
This commit is contained in:
@@ -15,7 +15,7 @@ import static java.lang.Math.*;
|
|||||||
* |isValidOrientation(getOrientation())
|
* |isValidOrientation(getOrientation())
|
||||||
* @invar The radius of the worm mus be a valid radius.
|
* @invar The radius of the worm mus be a valid radius.
|
||||||
* |isValidMinRadius(getRadius())
|
* |isValidMinRadius(getRadius())
|
||||||
* @invar The mass of the worm must be a valid mass.
|
* @invar The mass of the worm must bef a valid mass.
|
||||||
* |isValidMass(getMass())
|
* |isValidMass(getMass())
|
||||||
* @invar The value of the action points of the worm must be a valid value for action points.
|
* @invar The value of the action points of the worm must be a valid value for action points.
|
||||||
* |isValidValueActionPoints(getActionPoints())
|
* |isValidValueActionPoints(getActionPoints())
|
||||||
@@ -442,7 +442,7 @@ public class Worm {
|
|||||||
* substract the current points of the worm
|
* substract the current points of the worm
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* the value which should be substracted
|
* the value which should be subtracted
|
||||||
* @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
|
||||||
* |setActionPoints(getActionPoints() - value)
|
* |setActionPoints(getActionPoints() - value)
|
||||||
*/
|
*/
|
||||||
@@ -582,8 +582,8 @@ public class Worm {
|
|||||||
if (cost > getActionPoints())
|
if (cost > getActionPoints())
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
double distanceX = this.radius * cos(getOrientation());
|
double distanceX = getRadius() * cos(getOrientation());
|
||||||
double distanceY = this.radius * sin(getOrientation());
|
double distanceY = getRadius() * sin(getOrientation());
|
||||||
setLocation(Tuple.create(getLocation().item1 + numberSteps * distanceX,
|
setLocation(Tuple.create(getLocation().item1 + numberSteps * distanceX,
|
||||||
getLocation().item2 + numberSteps * distanceY));
|
getLocation().item2 + numberSteps * distanceY));
|
||||||
subtractActionPoints(cost);
|
subtractActionPoints(cost);
|
||||||
@@ -629,7 +629,7 @@ public class Worm {
|
|||||||
| (getActionPoints() - (long) ceil(toDegrees(angle) / 6) >= 0) )
|
| (getActionPoints() - (long) ceil(toDegrees(angle) / 6) >= 0) )
|
||||||
*/
|
*/
|
||||||
private boolean canTurn(double angle) {
|
private boolean canTurn(double angle) {
|
||||||
double currentAngle = this.getOrientation();
|
double currentAngle = getOrientation();
|
||||||
return 0 <= angle + currentAngle && angle + currentAngle < (2 * PI) &&
|
return 0 <= angle + currentAngle && angle + currentAngle < (2 * PI) &&
|
||||||
!Double.isNaN(angle) &&
|
!Double.isNaN(angle) &&
|
||||||
getActionPoints() - (long) ceil(toDegrees(angle) / 6) >= 0;
|
getActionPoints() - (long) ceil(toDegrees(angle) / 6) >= 0;
|
||||||
|
@@ -43,6 +43,8 @@ public class IllegalNameException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the index of this illegal name exception.
|
* Return the index of this illegal name exception.
|
||||||
|
*
|
||||||
|
* @return this.index
|
||||||
*/
|
*/
|
||||||
@Basic @Immutable
|
@Basic @Immutable
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
@@ -51,6 +53,8 @@ public class IllegalNameException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of this illegal name exception.
|
* Return the name of this illegal name exception.
|
||||||
|
*
|
||||||
|
* @return this.name
|
||||||
*/
|
*/
|
||||||
@Basic @Immutable
|
@Basic @Immutable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Reference in New Issue
Block a user