changed move

This commit is contained in:
2018-02-27 12:24:44 +01:00
parent 3545ff3894
commit e58c4a2656

View File

@@ -94,7 +94,13 @@ public class Worm {
return this.orientation; return this.orientation;
} }
/**
* @param orientation
*
*/
public void setOrientation(double orientation) { public void setOrientation(double orientation) {
this.orientation = orientation; this.orientation = orientation;
} }
@@ -150,7 +156,7 @@ public class Worm {
/** /**
* *
* @param NumberSteps * @param NumberSteps ...
* *
* @post ... * @post ...
* |new.CoordX = CoordX + NumberSteps * distanceX * |new.CoordX = CoordX + NumberSteps * distanceX
@@ -165,9 +171,9 @@ public class Worm {
public void move(int NumberSteps) { public void move(int NumberSteps) {
if (NumberSteps < 0) if (NumberSteps < 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
double distanceX = getRadius() * Math.cos(getOrientation()); double distanceX = this.radius * Math.cos(this.orientation);
double distanceY = getRadius() * Math.sin(getOrientation()); double distanceY = this.radius * Math.sin(this.orientation);
setCoordX(getCoordX() + NumberSteps * distanceX); setCoordX(this.coordX + NumberSteps * distanceX);
setCoordY(getCoordY() + NumberSteps * distanceY); setCoordY(this.coordY + NumberSteps * distanceY);
} }
} }