move function

This commit is contained in:
Leen Dereu
2018-02-27 12:31:33 +01:00
parent 4a370d2d90
commit 4d1c5ad2e3

View File

@@ -155,12 +155,7 @@ public class Worm {
} }
/** /**
<<<<<<< HEAD
* @param NumberSteps
=======
*
* @param NumberSteps ... * @param NumberSteps ...
>>>>>>> e58c4a26566e73a84d38d7f871aa21b85f295ea8
* *
* @post the new x-coordinate schould be the old one plus the number of steps multiplied * @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 * with the distance of a step in the x-orientation
@@ -176,11 +171,11 @@ 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();
<<<<<<< HEAD
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);
} }
/** /**
@@ -197,12 +192,5 @@ public class Worm {
*/ */
public void turn(double angleToAdd) { public void turn(double angleToAdd) {
assert 0 <= angleToAdd && angleToAdd < 2 * Math.PI; assert 0 <= angleToAdd && angleToAdd < 2 * Math.PI;
=======
double distanceX = this.radius * Math.cos(this.orientation);
double distanceY = this.radius * Math.sin(this.orientation);
setCoordX(this.coordX + NumberSteps * distanceX);
setCoordY(this.coordY + NumberSteps * distanceY);
>>>>>>> e58c4a26566e73a84d38d7f871aa21b85f295ea8
} }
} }