java.lang.Object
edu.ntnu.idatt1002.k01g08.fta.registers.TeamRegister
All Implemented Interfaces:
Iterable<Team>

public class TeamRegister extends Object implements Iterable<Team>
Represents a register of football teams
  • Constructor Details

    • TeamRegister

      public TeamRegister()
      Creates a team register
  • Method Details

    • addTeam

      public void addTeam(Team team) throws IllegalArgumentException
      Add a team to the register
      Parameters:
      team - is the team getting added to the register
      Throws:
      IllegalArgumentException - if the team is the team is already in the register
    • removeTeam

      public boolean removeTeam(Team team)
      Remove a team from the register
      Parameters:
      team - is the team getting removed from the register
      Returns:
      true or false
    • clearRegister

      public void clearRegister()
      Method for clearing the register
    • getTeams

      public Map<String,Team> getTeams()
      Method for retrieving the teams in the register
      Returns:
      a copy of the register as an ArrayList
    • getTeam

      public Team getTeam(String teamName) throws IllegalArgumentException
      Method for retrieving a specific team from the register
      Parameters:
      teamName - is the name of the team
      Returns:
      the Team
      Throws:
      IllegalArgumentException - if the team isn't in the register
    • getNumberOfTeams

      public int getNumberOfTeams()
      Find the number of teams in the register
      Returns:
      the number of teams in the register as an int
    • hasTeams

      public boolean hasTeams()
      Checks if the team-register has any teams registered
      Returns:
      true if it contains any teams
    • toString

      public String toString()
      toString
      Overrides:
      toString in class Object
      Returns:
      information about the teams in the register as a String
    • iterator

      public Iterator<Team> iterator()
      Specified by:
      iterator in interface Iterable<Team>