aanpassen commentaar
This commit is contained in:
@@ -657,13 +657,13 @@ public class Worm {
|
|||||||
*
|
*
|
||||||
* @post the worm jumps to his new place. The new place is the x-coordinate plus the jump distance
|
* @post the worm jumps to his new place. The new place is the x-coordinate plus the jump distance
|
||||||
* with the jump velocity
|
* with the jump velocity
|
||||||
* |worms.util.Tuple.create(location.item1 + jumpDistance(this.jumpVelocity), location.item2)
|
* |setLocation(Tuple.create(getLocation().item1 + jumpDistance(this.jumpVelocity()), getLocation().item2))
|
||||||
* @post the current action actionPoints schould be 0 after a jump
|
* @post the current action actionPoints schould be 0 after a jump
|
||||||
* |this.actionPoints = 0
|
* |setActionPoints(0)
|
||||||
* @throws IllegalStateException
|
* @throws IllegalStateException
|
||||||
* if the current action actionPoints is equal to 0 or the orientation is more then
|
* if the current action actionPoints is equal to 0 or the orientation is more then
|
||||||
* pi the worm can not jump
|
* pi the worm can not jump
|
||||||
* |this.actionPoints == 0 || this.orientation < Math.PI
|
* |!canJump()
|
||||||
*/
|
*/
|
||||||
public void jump() throws IllegalStateException {
|
public void jump() throws IllegalStateException {
|
||||||
|
|
||||||
@@ -680,6 +680,9 @@ public class Worm {
|
|||||||
* @return the time the worm will jump. The distance divided by the velocity multiplied
|
* @return the time the worm will jump. The distance divided by the velocity multiplied
|
||||||
* with the cosinus of the orientation
|
* with the cosinus of the orientation
|
||||||
* |jumpDistance(this.jumpVelocity) / (this.jumpVelocity * Math.cos(this.orientation))
|
* |jumpDistance(this.jumpVelocity) / (this.jumpVelocity * Math.cos(this.orientation))
|
||||||
|
* @throws IllegalStateException
|
||||||
|
* Orientation is bigger then pi or action points is equal to 0
|
||||||
|
* |getOrientation() >= PI || getActionPoints() == 0
|
||||||
*/
|
*/
|
||||||
public double jumpTime() {
|
public double jumpTime() {
|
||||||
|
|
||||||
@@ -716,7 +719,7 @@ public class Worm {
|
|||||||
*
|
*
|
||||||
* @return True if and only if the action actionPoints is bigger then 0 and the orientation
|
* @return True if and only if the action actionPoints is bigger then 0 and the orientation
|
||||||
* is lower then pi
|
* is lower then pi
|
||||||
* |result == this.actionPoints > 0 && this.orientation < Math.PI
|
* |result == getActionPoints() > 0 && getOrientation() < PI
|
||||||
*/
|
*/
|
||||||
private boolean canJump() {
|
private boolean canJump() {
|
||||||
return getActionPoints() > 0 && getOrientation() < PI;
|
return getActionPoints() > 0 && getOrientation() < PI;
|
||||||
@@ -729,7 +732,7 @@ public class Worm {
|
|||||||
* The velocity of the jump
|
* The velocity of the jump
|
||||||
* @return The distance the worm will jump. The distance is equal to the velocity powered by 2 multiplied
|
* @return The distance the worm will jump. The distance is equal to the velocity powered by 2 multiplied
|
||||||
* with the sinus of 2 times the orientation en this divided with the gravity
|
* with the sinus of 2 times the orientation en this divided with the gravity
|
||||||
* |(Math.pow(v, 2) * Math.sin(2 * this.orientation)) / this.G
|
* |(pow(v, 2) * sin(2 * getOrientation())) / G
|
||||||
*/
|
*/
|
||||||
private double jumpDistance(double v) {
|
private double jumpDistance(double v) {
|
||||||
return (pow(v, 2) * sin(2 * getOrientation())) / G;
|
return (pow(v, 2) * sin(2 * getOrientation())) / G;
|
||||||
@@ -741,8 +744,8 @@ public class Worm {
|
|||||||
* @return the velocity of the jump. The force of the jump is equal to 5 multiplied with the
|
* @return the velocity of the jump. The force of the jump is equal to 5 multiplied with the
|
||||||
* current action actionPoints plus the mass multiplied with the gravity. Therefrom the velocity
|
* current action actionPoints plus the mass multiplied with the gravity. Therefrom the velocity
|
||||||
* is equal to the force divided with the mass, multiplied with the time te force takes
|
* is equal to the force divided with the mass, multiplied with the time te force takes
|
||||||
* |force = 5 * this.actionPoints + this.mass * G
|
* |force = 5 * getActionPoints() + getMass() * G
|
||||||
* |velocity = (force / this.mass) * FORCE_TIME
|
* |velocity = (force / getMass()) * FORCE_TIME
|
||||||
*/
|
*/
|
||||||
private double jumpVelocity() {
|
private double jumpVelocity() {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user