java.lang.Object
edu.ntnu.idatt1002.g106.handballapp.finalprod.backend.Tournament
All Implemented Interfaces:
Serializable

public class Tournament extends Object implements Serializable
This is a class which creates the structure of tournament. Therefore, it contains all the relevant fields and methods which define a tournament. These methods include storage and manipulations of matches.
Author:
Gruppe 6
See Also:
  • Field Details

    • tournamentID

      private int tournamentID
    • matchList

      private List<Match> matchList
    • startDate

      private LocalDate startDate
    • endDate

      private LocalDate endDate
    • teamRegister

      private TeamRegister teamRegister
    • results

      private Results results
    • tournamentPlace

      private String tournamentPlace
    • numFields

      private int numFields
    • numTeams

      private int numTeams
    • tournamentName

      private String tournamentName
    • roundTeamList

      private List<List<Team>> roundTeamList
    • roundMatchList

      private List<List<Match>> roundMatchList
    • currentRound

      private int currentRound
    • region

      private String region
  • Constructor Details

    • Tournament

      public Tournament(int tournamentID, String tournamentName, LocalDate startDate, LocalDate endDate, String tournamentPlace, int numFields, int numTeams, String region) throws IllegalArgumentException
      This is a constructor which allows for a tournament object to be initialized. The constructor gathers the vital information for structuring a tournament.
      Parameters:
      tournamentID - The identification number for a tournament, represented as an int
      startDate - The date for which the tournament starts, represented as a LocalDate
      endDate - The date for which the tournament ends, represented as a LocalDate
      Throws:
      IllegalArgumentException
  • Method Details

    • generateTournament

      public void generateTournament()
      This method fills out the MatchList for each round by assigning times for the whole tournament. No two consecutive rounds will overlap.
    • makeSchedule

      public List<LocalDateTime> makeSchedule()
      This method creates a list of equally spaced out times for the given start and end date based on the number of fields and the restricted start time: 9:00-21:00.
      Returns:
      A list of all the times for all the matches
    • getTimeBetweenMatches

      public double getTimeBetweenMatches()
      This method gets the amount of time needed between matches
      Returns:
      Time between matches in tournament, represented by double
    • getTimeBetweenMatchesRounded

      public int getTimeBetweenMatchesRounded()
      If we want times for matches that start at exactly hh:00, then this method is used in make schedule instead of the one above.
      Returns:
      A rounded time interval between matches, represented as an int
    • totalIntervalsNeeded

      public int totalIntervalsNeeded()
      This method finds the total number of intervals of games needed in order to ensure that no two rounds overlap while considering all fields.
      Returns:
      The total amount of intervals needed to split the total tournament time, represented as an int
    • intervalTakenByRound

      public int intervalTakenByRound(int round)
      This method checks the intervals taken by a given round
      Parameters:
      round - The given round, represented as an int
      Returns:
      The interval take by a given round
    • checkNumMatchesByRound

      public int checkNumMatchesByRound(int round)
      This method returns the amount of matches in the given round
      Parameters:
      round - The current round, represented as an int
      Returns:
      Number of matches in the round, represented as an int
    • checkAmountRounds

      public int checkAmountRounds()
      This method checks how many rounds will exist in the given tournament.
      Returns:
      Number of rounds, represented as an int
    • generateRoundWithTeams

      public void generateRoundWithTeams(int round) throws IllegalArgumentException
      This method adds all the winning teams to matches for the next round.
      Parameters:
      round - The current round of the tournament, represented as an int
      Throws:
      IllegalArgumentException
    • updateAllTeamsInTournament

      public void updateAllTeamsInTournament()
      This method updates all the teams in the tournament's information.
    • updateTeamInfoByName

      public void updateTeamInfoByName(String teamName)
      This method updates a given team's information (goals, wins, and losses).
      Parameters:
      teamName - Name of team, represented as a String
    • setWinsOfTeamByName

      public void setWinsOfTeamByName(String teamName)
      This method sets the total wins of a team, during the tournament, based on each match played
      Parameters:
      teamName - Name of the team, represented as a String
    • setLosesOfTeamByName

      public void setLosesOfTeamByName(String teamName)
      This method sets the total losses of a team, during the tournament, based on each match played
      Parameters:
      teamName - Name of the team, represented as a String
    • setTotalGoalsOfTeamByName

      public void setTotalGoalsOfTeamByName(String teamName)
      This method sets the total goals of a team, during the tournament, based on each match played
      Parameters:
      teamName - Name of a team, represented as a String
    • setFirstTeamsList

      public void setFirstTeamsList()
      This method sets the first teams list full with the team register.
    • getTournamentName

      public String getTournamentName()
      getMethod that gets Tournament Name
      Returns:
      tournament name as a String
    • addMatch

      public boolean addMatch(Match match)
      This method adds a match to the list of matches
      Parameters:
      match - Match to be added
      Returns:
      Status whether the match was added, if it's already in the list it returns false, if it's added true
    • removeMatchByMatchID

      public boolean removeMatchByMatchID(int matchID)
      This method removes a match from the list based on a given matchID
      Parameters:
      matchID - A match's identification number, represented as an int
      Returns:
      Status on whether it was successfully removed, true if it was, false if it wasn't
    • getMatchList

      public List<Match> getMatchList()
      This method retrieves the tournament list of matches.
      Returns:
      List of matches registered in the tournament
    • getTournamentID

      public int getTournamentID()
      This method retrieves the tournament's identification number
      Returns:
      Tournament's identification number, represented as an int
    • getStartDate

      public LocalDate getStartDate()
      This method retrieves the tournament's start date.
      Returns:
      The start date of the tournament, represented as a LocalDate object
    • getEndDate

      public LocalDate getEndDate()
      This method retrieves the tournament's end date.
      Returns:
      The end date of the tournament, represented as a LocalDate object
    • getTeamRegister

      public TeamRegister getTeamRegister()
      This method retrieves the team register of the tournament.
      Returns:
      Team register object over tournament
    • getRoundTeamList

      public List<List<Team>> getRoundTeamList()
      This method retrieves the list of winning teams for each round.
      Returns:
      List of winning teams, represented using Team objects
    • getRoundMatchList

      public List<List<Match>> getRoundMatchList()
      This method returns the list of matches for each round.
      Returns:
      List of Match objects for each round
    • getCurrentRound

      public int getCurrentRound()
      this method gets the current round of the tournament, used when generations of matches
      Returns:
      int value of the current round
    • getNumTeams

      public int getNumTeams()
      get the number of remaining teams
      Returns:
      in of remaining teams
    • getRegion

      public String getRegion()
      gets the region of the tournament
      Returns:
      string of the region
    • toString

      public String toString()
      toString method for returning all Tournament information
      Overrides:
      toString in class Object
      Returns:
      all Tournament information as a String