turn function
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +155,12 @@ 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
|
||||||
@@ -165,6 +176,7 @@ 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 = getRadius() * Math.cos(getOrientation());
|
||||||
double distanceY = getRadius() * Math.sin(getOrientation());
|
double distanceY = getRadius() * Math.sin(getOrientation());
|
||||||
setCoordX(getCoordX() + numberSteps * distanceX);
|
setCoordX(getCoordX() + numberSteps * distanceX);
|
||||||
@@ -186,5 +198,11 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user