From 5c64518c41eea2e4b16508beac14a57e2336d06e Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 24 May 2018 12:14:45 +0200 Subject: [PATCH] Documentatie Coordinate --- OGP1718-Worms/src/worms/util/Coordinate.java | 50 +++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/OGP1718-Worms/src/worms/util/Coordinate.java b/OGP1718-Worms/src/worms/util/Coordinate.java index 7c2d146..84e2a9a 100644 --- a/OGP1718-Worms/src/worms/util/Coordinate.java +++ b/OGP1718-Worms/src/worms/util/Coordinate.java @@ -6,11 +6,18 @@ import be.kuleuven.cs.som.annotate.Value; @Value public class Coordinate extends Tuple { + /** - * Initialize this new Tuple as a Tuple with the given items. + * @param coordinateX + * @param coordinateY * - * @param coordinateX The x-coordinate for this Coordinate - * @param coordinateY The y-coordinate for this Coordinate + * @post ... + * |new.this.item1 == coordinateX + * @post ... + * |new.this.item2 == coordinateY + * + * @throws IllegalArgumentException ... + * | */ public Coordinate(double coordinateX, double coordinateY) throws IllegalArgumentException { super(coordinateX, coordinateY); @@ -19,12 +26,10 @@ public class Coordinate extends Tuple { /** * * @param coordinateX - * The value for the x-coordinate. * @param coordinateY - * The value for the y-coordinate. - * @return - * The coordinate created from coordinateX and coordinateY. - * | result == new Coordinate(coordinateX, coordinateY); + * + * @return ... + * |result == new Coordinate(coordinateX, coordinateY); */ @Immutable public static Coordinate create(double coordinateX, double coordinateY){ @@ -32,16 +37,13 @@ public class Coordinate extends Tuple { } /** - * Return a new Coordinate created from the elements of the array. - * * @param arr - * The Array to create the Coordinate of. - * @return The Tuple created from the elements of the given array. - * | result == new Coordinate(arr[0], arr[1]) - * @throws IllegalArgumentException - * The given array is null or the length of the given array - * is not 2. - * | arr == null || arr.length != 2 + * + * @return ... + * |result == new Coordinate(arr[0], arr[1]) + * + * @throws IllegalArgumentException ... + * |arr == null || arr.length != 2 */ @Immutable public static Coordinate create(double[] arr) throws IllegalArgumentException { @@ -50,15 +52,27 @@ public class Coordinate extends Tuple { return new Coordinate(arr[0], arr[1]); } + /** + * @return ... + * |result == new double[]{getX(), getY()} + */ public double[] toArray() { - return new double[]{getX(), getY()}; } + /** + * @return ... + * |result == this.item1 + */ @Basic @Immutable public double getX() { return this.item1; } + + /** + * @return ... + * |result == this.item2 + */ @Basic @Immutable public double getY() { return this.item2;