Class Tournament
java.lang.Object
edu.ntnu.idatt1002.g106.handballapp.finalprod.backend.Tournament
- All Implemented Interfaces:
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
This method adds a match to the list of matchesint
This method checks how many rounds will exist in the given tournament.int
checkNumMatchesByRound
(int round) This method returns the amount of matches in the given roundvoid
generateRoundWithTeams
(int round) This method adds all the winning teams to matches for the next round.void
This method fills out the MatchList for each round by assigning times for the whole tournament.int
this method gets the current round of the tournament, used when generations of matchesThis method retrieves the tournament's end date.This method retrieves the tournament list of matches.int
get the number of remaining teamsgets the region of the tournamentThis method returns the list of matches for each round.This method retrieves the list of winning teams for each round.This method retrieves the tournament's start date.This method retrieves the team register of the tournament.double
This method gets the amount of time needed between matchesint
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.int
This method retrieves the tournament's identification numbergetMethod that gets Tournament Nameint
intervalTakenByRound
(int round) This method checks the intervals taken by a given roundThis 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.boolean
removeMatchByMatchID
(int matchID) This method removes a match from the list based on a given matchIDvoid
This method sets the first teams list full with the team register.void
setLosesOfTeamByName
(String teamName) This method sets the total losses of a team, during the tournament, based on each match playedvoid
setTotalGoalsOfTeamByName
(String teamName) This method sets the total goals of a team, during the tournament, based on each match playedvoid
setWinsOfTeamByName
(String teamName) This method sets the total wins of a team, during the tournament, based on each match playedtoString()
toString method for returning all Tournament informationint
This method finds the total number of intervals of games needed in order to ensure that no two rounds overlap while considering all fields.void
This method updates all the teams in the tournament's information.void
updateTeamInfoByName
(String teamName) This method updates a given team's information (goals, wins, and losses).
-
Field Details
-
tournamentID
private int tournamentID -
matchList
-
startDate
-
endDate
-
teamRegister
-
results
-
tournamentPlace
-
numFields
private int numFields -
numTeams
private int numTeams -
tournamentName
-
roundTeamList
-
roundMatchList
-
currentRound
private int currentRound -
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 intstartDate
- The date for which the tournament starts, represented as a LocalDateendDate
- 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
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
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
This method updates a given team's information (goals, wins, and losses).- Parameters:
teamName
- Name of team, represented as a String
-
setWinsOfTeamByName
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
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
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
getMethod that gets Tournament Name- Returns:
- tournament name as a String
-
addMatch
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
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
This method retrieves the tournament's start date.- Returns:
- The start date of the tournament, represented as a LocalDate object
-
getEndDate
This method retrieves the tournament's end date.- Returns:
- The end date of the tournament, represented as a LocalDate object
-
getTeamRegister
This method retrieves the team register of the tournament.- Returns:
- Team register object over tournament
-
getRoundTeamList
This method retrieves the list of winning teams for each round.- Returns:
- List of winning teams, represented using Team objects
-
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
gets the region of the tournament- Returns:
- string of the region
-
toString
toString method for returning all Tournament information
-