From 8b4e147d9e5ce3b52fb1ba21fa8203bc9a123d23 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Wed, 23 May 2018 16:01:10 +0200 Subject: [PATCH] Documentatie Team --- OGP1718-Worms/src/worms/model/Team.java | 48 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/OGP1718-Worms/src/worms/model/Team.java b/OGP1718-Worms/src/worms/model/Team.java index 77eef48..c510338 100644 --- a/OGP1718-Worms/src/worms/model/Team.java +++ b/OGP1718-Worms/src/worms/model/Team.java @@ -13,13 +13,17 @@ public class Team { //=================================================================================== /** - * - * @param name - * - * @post ... - * |setName(name) - * @post ... + * Initialize a new team with given name and world. + * + * @param name the name of the team. + * + * @post The new name of the team is equal to the given name. + * |new.getName == name + * @post The collection of worms in a team is a new Treeset (with TeamComparator). * |wormCollection = new Treeset<>(new TeamComparator()) + * @post If the world is not equal to null, the team would be add to the world + * |if (world != null) + * | world.addTeam(this) */ public Team (String name, World world) { setName(name); @@ -32,6 +36,17 @@ public class Team { //=================================================================================== // endregion + /** + * Check whether the given object has a valid name for a object. + * + * @param obj the object to check + * + * @return True if and only if the name of the given object is not equal to the name of an other object. + * The object can only be a team. + * |if (! obj instanceof Team) + * | result == false + * |result == this.getName().equals((Team) obj).getName()) + */ @Override public boolean equals(Object obj) { if (!(obj instanceof Team)) return false; @@ -43,16 +58,17 @@ public class Team { // region changesTeam //=================================================================================== - /** - * @param worm - * - * @post ... - * |new.team = old.team + worm - * - * @throws IllegalArgumentException - * ... - * |worm == null || ! canHaveAsWorm(worm) - */ + /** + * Adds the given worms to the team. + * + * @param worms The worms to add. + * + * @post + * + * @throws IllegalArgumentException Given worm is null + * |worms == null + * @throws IllegalArgumentException + */ public void addWorm(Worm... worms) throws IllegalArgumentException { if (worms == null) throw new IllegalArgumentException(); if (!canHaveAsWorm(worms)) throw new IllegalArgumentException();