From 183caf85b40ff280dd208971febf995f080b0938 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Mon, 16 Apr 2018 21:29:13 +0200 Subject: [PATCH] Documentatie move methodes --- OGP1718-Worms/src/worms/model/Worm.java | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 3f29459..f338119 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -551,8 +551,15 @@ public class Worm extends GameObject { } /** + * Gives the direction in which the furthest location is maximal. * - * @return + * @return The direction in which the furthest location is maximal. Where the distance between + * the center and a point on the circle (shape of worm) maximal is. The furthes location + * has to be passable. + * |for each direction: + * | if new.getDistance > maxDistance: + * | maxDistance == new.getDistance + * |result == maxDistance */ public double getFurthestLocationDirection() { Coordinate location = getLocation(); @@ -574,11 +581,35 @@ public class Worm extends GameObject { return maxLocDirection; } + /** + * Gives the distance between two coordinates. + * + * @param start + * The start coordinate of the equation. + * @param end + * The end coordinate of the equation. + * + * @return the distance between the two given coordinates. The distance is equal to + * the square root of the square of the displacement of the x coordinate plus the + * square of the displacement of the y coordinate. + * |result == sqrt(pow(start.getX()-end.getX())+pow(start.getY()-end.getY())) + */ public double getDistance(Coordinate start, Coordinate end) { return Math.sqrt(Math.pow(Math.abs(start.getX() - end.getX()), 2) + Math.pow(Math.abs(start.getY() - end.getY()), 2)); } + /** + * The clashing worms their hit points are reduced. + * + * @param basicWorm + * The worm who has moved. + * @param worm + * The worms who has clashed with the basicworm. + * + * @post All the worms that clashed their hitpoints are reduced. There is a random integer between + * 1 and 10 (= N). The lose of the smalles worm is equal to N divided by the orientation o + */ public void collision(Worm basicWorm, Worm... worm) { Worm largestWorm; Worm smallestWorm;