diff --git a/Dereu_Bols.jar b/Dereu_Bols.jar new file mode 100644 index 0000000..56a8653 Binary files /dev/null and b/Dereu_Bols.jar differ diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 65e1428..55c7db8 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -147,7 +147,8 @@ public class Worm { * the location to check * @return True if and only if the location is not equal to null and the coordinates of * the worm are numbers - * |result == (location != null) && (!Double.isNaN(location.item1)) && (!Double.isNaN(location.item2)) + * |result == ( (location != null) && (location.item1 != null) && (location.item2 != null) + * |&& (!Double.isNaN(location.item1)) && (!Double.isNaN(location.item2)) ) */ public static boolean isValidLocation(Tuplelocation) { return location != null && location.item1 != null && location.item2 != null @@ -218,9 +219,12 @@ public class Worm { } /** + *check whether the given orientation is a valid orientation for the worm * * @param newOrientation - * @return + * the orientation to check + * @return True if and only if the orientation is bigger then and smaller then 2pi + * |result == ( newOrientation >= 0 && newOrientation < 2 * PI ) */ public static boolean isValidOrientation(double newOrientation) { return newOrientation >= 0 && newOrientation < 2 * PI; @@ -298,8 +302,6 @@ public class Worm { */ private final double minRadius; - - /** * Check whether the given radius is a valid radius for the worm * @@ -307,7 +309,7 @@ public class Worm { * the radius to check * @return True if and only if the radius is bigger then the minimum radius * (or equal) and the radius is a number - * |result == (radius >= this.minRadius && !Double.isNaN(radius)) + * |result == (radius >= getMinRadius() && !Double.isNaN(radius)) */ @Raw private boolean canHaveAsRadius(double radius) { @@ -554,18 +556,18 @@ public class Worm { * the old x-coordinate plus the number of steps multiplied with the distance * that the x-coordinate schould move (distance is equal to the radius multiplied * with the cosinus of the orientation) - * |distanceX = this.radius * Math.cos(this.orientation) - * |new.xCoordinate = this.location.item1 + numberSteps * distanceX + * |distanceX = this.radius * cos(getOrientation()) + * |new.xCoordinate = getLocation().item1 + numberSteps * distanceX * @post the y-coordinate of the new location of the worm schould be the location of * the old y-coordinate plus the number of steps multiplied with the distance * that the y-coordinate schould move (distance is equal to the radius multiplied * with the sinus of the orientation) - * |distanceY = this.radius * Math.sin(this.orientation) - * |new.yCoordinate = this.location.item2 + numberSteps * distanceY + * |distanceY = this.radius * sin(getOrientation()) + * |new.yCoordinate = getLocation().item2 + numberSteps * distanceY * @post the current value of action actionPoints has changed. The current value of action actionPoints * minus the cost of moving (abs(cos(theta)) + abs(4 sin(theta))) - * |value = (int) Math.ceil(Math.abs(Math.cos(this.orientation)) + Math.abs(4 * Math.sin(this.orientation))) - * |setActionPoints(this.actionPoints - value) + * |cost = (long) ceil(abs(cos(getOrientation())) + abs(4 * sin(getOrientation()))) * numberSteps + * |subtractActionPoints(cost) * @throws IllegalArgumentException * when the total of steps is lower then 0 or when the cost of action point is more * then the current value of action point @@ -655,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 * 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 - * |this.actionPoints = 0 + * |setActionPoints(0) * @throws IllegalStateException * if the current action actionPoints is equal to 0 or the orientation is more then * pi the worm can not jump - * |this.actionPoints == 0 || this.orientation < Math.PI + * |!canJump() */ public void jump() throws IllegalStateException { @@ -678,6 +680,9 @@ public class Worm { * @return the time the worm will jump. The distance divided by the velocity multiplied * with the cosinus of the 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() { @@ -714,7 +719,7 @@ public class Worm { * * @return True if and only if the action actionPoints is bigger then 0 and the orientation * is lower then pi - * |result == this.actionPoints > 0 && this.orientation < Math.PI + * |result == getActionPoints() > 0 && getOrientation() < PI */ private boolean canJump() { return getActionPoints() > 0 && getOrientation() < PI; @@ -727,7 +732,7 @@ public class Worm { * The velocity of the jump * @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 - * |(Math.pow(v, 2) * Math.sin(2 * this.orientation)) / this.G + * |(pow(v, 2) * sin(2 * getOrientation())) / G */ private double jumpDistance(double v) { return (pow(v, 2) * sin(2 * getOrientation())) / G; @@ -739,8 +744,8 @@ public class Worm { * @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 * is equal to the force divided with the mass, multiplied with the time te force takes - * |force = 5 * this.actionPoints + this.mass * G - * |velocity = (force / this.mass) * FORCE_TIME + * |force = 5 * getActionPoints() + getMass() * G + * |velocity = (force / getMass()) * FORCE_TIME */ private double jumpVelocity() {