java.lang.Object
edu.ntnu.idatt1002.k01g08.fta.objects.team.Team
Represents a team of football players
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the given player to this team, if its squad number is not shared by any player already present.boolean
addPlayers
(Collection<? extends Player> players) Tries to add all the players in the given collection to the team.getName()
Returns the name of this team.getPlayer
(int number) Returns the player with the given squad number.iterator()
Returns an iterator over the players in this team.boolean
removePlayer
(int number) Tries to remove the player with the given squad number from this tram.boolean
removePlayer
(Player player) Tries to remove the given player from this team.int
size()
Returns the number of players on this team.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Team
Creates a team instance, with the given name.- Parameters:
name
- the name of the team
-
-
Method Details
-
getName
Returns the name of this team.- Returns:
- the name of this team
-
getPlayer
Returns the player with the given squad number. If no player has the number, returns null.- Parameters:
number
- the squad number of the player- Returns:
- the player with the given squad number, or null
-
size
public int size()Returns the number of players on this team.- Returns:
- the number of players on this team
-
addPlayer
Adds the given player to this team, if its squad number is not shared by any player already present. Returns true if the player was added, and false if not.- Parameters:
player
- a player to be added to this team- Returns:
- true if the player was added, false if not
- Throws:
NullPointerException
- if player is null
-
addPlayers
Tries to add all the players in the given collection to the team. Returns true if any of the players were added.- Parameters:
players
- a player to be added to this team- Returns:
- true any of the players were added
- Throws:
NullPointerException
- if player is null
-
removePlayer
Tries to remove the given player from this team. Returns true if the player was present, and false if not.- Parameters:
player
- a player to be removed from this team- Returns:
- true if a player was removed, false if not
-
removePlayer
public boolean removePlayer(int number) Tries to remove the player with the given squad number from this tram. Returns true if a player with that squad number was present, and false if not.- Parameters:
number
- the squad number of the player to be removed from this team- Returns:
- true if a player was removed, false if not
-
iterator
Returns an iterator over the players in this team. -
toString
-