From e4c938dbcd293b3c59e8bfb8aa0ca75b99d33798 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 24 May 2018 12:33:35 +0200 Subject: [PATCH] Documentatie Tuple --- OGP1718-Worms/src/worms/util/Tuple.java | 72 +++++++++++-------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/OGP1718-Worms/src/worms/util/Tuple.java b/OGP1718-Worms/src/worms/util/Tuple.java index 38276d9..d26d2c3 100644 --- a/OGP1718-Worms/src/worms/util/Tuple.java +++ b/OGP1718-Worms/src/worms/util/Tuple.java @@ -19,24 +19,22 @@ import java.util.Objects; @Value public class Tuple { - /** - * The variable referencing the first item of this Tuple. - */ + public final T1 item1; - /** - * The variable referencing the second item of this Tuple. - */ public final T2 item2; - /** - * Initialize this new Tuple as a Tuple with the given items. - * * @param item1 - * The first element for this tuple. * @param item2 - * The second element for this tuple. + * + * @post ... + * |this.item1 == item1 + * @post ... + * |this.item2 + * + * @throws IllegalArgumentException ... + * | */ public Tuple(T1 item1, T2 item2) throws IllegalArgumentException { @@ -45,14 +43,13 @@ public class Tuple { } /** + * @param item1 + * @param item2 + * @param + * @param * - * @param item1 - * The value for the first element. - * @param item2 - * The value for the second element. - * @return - * The Tuple created from item1 and item2. - * | result == new Tuple<>(item1, item2); + * @return ... + * |result == new Tuple<>(item1, item2) */ @Immutable public static Tuple create(T1 item1, T2 item2){ @@ -60,16 +57,13 @@ public class Tuple { } /** - * Return a new Tuple created from the elements of the array. + * @param arr * - * @param arr - * The Array to create the tuple of. - * @return The Tuple created from the elements of the given array. - * | result == new Tuple<>(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 Tuple<>(arr[0], arr[1]) + * + * @throws IllegalArgumentException ... + * |arr == null || arr.length != 2 */ @Immutable public static Tuple create(double[] arr) throws IllegalArgumentException { @@ -79,17 +73,15 @@ public class Tuple { } /** - * Compares the Tuple to the given object. - * * @param o - * The object to compare to. - * @return True if and only if the given object is this Tuple. - * | if (this == 0) then result == true - * Otherwise, true if the given object is a Tuple and - * the items are the same as this Tuple. - * | else result == - * | Objects.equals(item1, tuple.item1) && - * | Objects.equals(item2, tuple.item2); + * + * @return ... + * |if (this == o) + * | result == true + * |if (!(o instanceof Tuple)) + * | result == false + * |Tuple tuple = (Tuple o + * |result == Objects.equals(item1, tuple.item1) && Objects.equals(item2, tuple.item2) */ @Override public boolean equals(Object o) { @@ -101,10 +93,8 @@ public class Tuple { } /** - * Generates a hash code of the items of the Tuple - * - * @return The hash code of item1 and item2 - * | result == Objects.hash(item1, item2) + * @return ... + * |result == Objects.hash(item1, item2) */ @Override public int hashCode() {