Class Tournament
java.lang.Object
edu.ntnu.idatt1002.k01g08.fta.objects.tournaments.Tournament
- Direct Known Subclasses:
KnockOut
Class representing a Tournament
The Tournament's main function is to add, remove and modify matches which take place during the tournament.
It contains information about all teams and matches in the tournament in ArrayLists, as well as it's name and
start date as strings, the winning prize as an integer, the winning team and the expected match length as an
int representing minutes.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTournament
(String tournamentName) Constructor for object which represents an abstract tournament, mainly used for testing purposesTournament
(ArrayList<Team> teams, String tournamentName) Constructor for object which represents an abstract tournament, without a winning prize or dateTournament
(ArrayList<Team> teams, String tournamentName, int firstPrize, String startDate) Constructor for object which represents an abstract tournament with all inputsTournament
(ArrayList<Team> teams, String tournamentName, String startDate, int matchLength) Constructor for object which represents an abstract tournament, without a winning prize -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllTeams
(List<Team> newTeams) Method for adding all teams in a listvoid
Method for adding a team into the tournamentvoid
endMatch()
Method for ending a match, will remove match from list of future matches and set the current match to emptyboolean
abstract void
Abstract method for generating the next set of matches Will be called if there are no planned matches yet more teams leftMethod for finding the match currently being playedint
Method for finding the prize which the winner will receiveMethod for finding all finished matchesint
Method for finding the planned match time This is the length of the match in its entirety, so halftime starts at the middle of the inputted timeint
Method for finding how many teams who will participate in the tournamentMethod for finding the date of the tournamentgetTeams()
Method for finding all teams in the tournamentMethod for finding the name of the tournamentMethod for finding all planned matchesMethod for finding the team which won the tournamentvoid
setUpcomingMatch
(Team team1, Team team2) Method for planning a new matchvoid
Method for changing match winnervoid
Method for initiating the next matchtoString()
Method for acquiring information about the tournament
-
Field Details
-
previousRoundMatches
-
-
Constructor Details
-
Tournament
public Tournament(ArrayList<Team> teams, String tournamentName, int firstPrize, String startDate) throws IllegalArgumentException, NullPointerException Constructor for object which represents an abstract tournament with all inputs- Parameters:
teams
- a list of all teams in the tournamenttournamentName
- the name of the tournamentfirstPrize
- what you get for achieving first placestartDate
- when the tournament starts- Throws:
IllegalArgumentException
NullPointerException
-
Tournament
public Tournament(ArrayList<Team> teams, String tournamentName, String startDate, int matchLength) throws IllegalArgumentException, NullPointerException Constructor for object which represents an abstract tournament, without a winning prize- Parameters:
teams
- a list of all teams in the tournamenttournamentName
- the name of the tournamentstartDate
- when the tournament startsmatchLength
- the length which the match should be- Throws:
IllegalArgumentException
NullPointerException
-
Tournament
public Tournament(ArrayList<Team> teams, String tournamentName) throws IllegalArgumentException, NullPointerException Constructor for object which represents an abstract tournament, without a winning prize or date- Parameters:
teams
- a list of all teams in the tournamenttournamentName
- the name of the tournament- Throws:
IllegalArgumentException
NullPointerException
-
Tournament
Constructor for object which represents an abstract tournament, mainly used for testing purposes- Parameters:
tournamentName
- the name of the tournament- Throws:
IllegalArgumentException
NullPointerException
-
-
Method Details
-
setUpcomingMatch
Method for planning a new match- Parameters:
team1
- first team competing in the matchteam2
- second team competing in the match
-
startNextMatch
public void startNextMatch()Method for initiating the next match -
endMatch
public void endMatch()Method for ending a match, will remove match from list of future matches and set the current match to empty -
getCurrentMatch
Method for finding the match currently being played- Returns:
- the match currently being played
-
getMatchLength
public int getMatchLength()Method for finding the planned match time This is the length of the match in its entirety, so halftime starts at the middle of the inputted time- Returns:
- int showing how many minutes a match should last
-
findUpcomingMatches
public abstract void findUpcomingMatches()Abstract method for generating the next set of matches Will be called if there are no planned matches yet more teams left -
getWinner
Method for finding the team which won the tournament- Returns:
- the team who won the tournament
-
setWinner
Method for changing match winner- Parameters:
winner
- which team who should win the tournament
-
getTeams
Method for finding all teams in the tournament- Returns:
- a list of teams
-
getMatches
Method for finding all finished matches- Returns:
- a list of matches
-
getUpcomingMatches
Method for finding all planned matches- Returns:
- a list of matches
-
getTournamentName
Method for finding the name of the tournament- Returns:
- Name of the tournament
-
getFirstPrize
public int getFirstPrize()Method for finding the prize which the winner will receive- Returns:
- a number representing the first price value in kr
-
getStartDate
Method for finding the date of the tournament- Returns:
- a String representing the date of the tournament
-
getNumberOfTeams
public int getNumberOfTeams()Method for finding how many teams who will participate in the tournament- Returns:
- a number representing the number of teams
-
addTeam
Method for adding a team into the tournament- Parameters:
team
- to add
-
addAllTeams
Method for adding all teams in a list- Parameters:
newTeams
- to add
-
toString
Method for acquiring information about the tournament -
equals
-