Documentatie Team
This commit is contained in:
@@ -13,13 +13,17 @@ public class Team {
|
||||
//===================================================================================
|
||||
|
||||
/**
|
||||
* Initialize a new team with given name and world.
|
||||
*
|
||||
* @param name
|
||||
* @param name the name of the team.
|
||||
*
|
||||
* @post ...
|
||||
* |setName(name)
|
||||
* @post ...
|
||||
* @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();
|
||||
|
Reference in New Issue
Block a user