Class MatchRound
java.lang.Object
edu.ntnu.idatt1002.k2g05.models.rounds.Round
edu.ntnu.idatt1002.k2g05.models.rounds.MatchRound
- All Implemented Interfaces:
Serializable
A match round holds multiple match games, some examples of a match round would be a group-play or a semi-final, where
the matches that is in match round is a list of
MatchGame
.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMatchRound
(String name) Constructor for making an instance of a MatchRound.MatchRound
(String name, boolean isFinal) Constructor for making an instance of a MatchRound. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addMatchGame
(MatchGame matchGame) Method for adding matchGame to the round.void
clear()
Method for clearing the round of games.Method for getting all the matchGames in the round.int
Method for getting the amount of match games in the roundgetMatchGame
(int index) Get a specific matchGame given its insertion order (index) in the round.getTopMatchGames
(int n) Method for getting the top n matchGames in the round, "top" is defined by the points that the matchGames has If the n-th player and the n+1-th player has the same point score it will be up to the previous sorted arrangement of the games.boolean
isFinal()
boolean
removeMatchGame
(MatchGame matchGame) Removes the first occurrence of a matchGame from this round, if it is present.void
Method for sorting the matchGames in the round given a sort typevoid
Method for sorting the matchGames in the round given a sort type, and if it should be reversed.
-
Constructor Details
-
MatchRound
Constructor for making an instance of a MatchRound. Given the name. isFinal will be set to false.- Parameters:
name
- of the round
-
MatchRound
Constructor for making an instance of a MatchRound. Given the name and if it is a final- Parameters:
name
- of the roundisFinal
- true if yes.
-
-
Method Details
-
clear
public void clear()Description copied from class:Round
Method for clearing the round of games. -
addMatchGame
Method for adding matchGame to the round.- Parameters:
matchGame
- to be added ot the list- Returns:
true
(as specified byCollection.add(E)
)- Throws:
NullPointerException
- if the specified matchGame is null
-
getTopMatchGames
Method for getting the top n matchGames in the round, "top" is defined by the points that the matchGames has If the n-th player and the n+1-th player has the same point score it will be up to the previous sorted arrangement of the games.- Parameters:
n
- amount of top players to get- Returns:
- n top players
-
removeMatchGame
Removes the first occurrence of a matchGame from this round, if it is present. If this round does not contain the matchGame, it is unchanged. Returnstrue
if this list contained the specified matchGame (or equivalently, if this round changed as a result of the call).- Parameters:
matchGame
- to be removed- Returns:
true
if this round contained the specified matchGame
-
sort
Method for sorting the matchGames in the round given a sort type- Parameters:
sortType
- to sort by.
-
getAmountMatchGames
public int getAmountMatchGames()Method for getting the amount of match games in the round- Returns:
- the amount of match games.
-
getAllMatchGames
Method for getting all the matchGames in the round.- Returns:
- all the match games
-
getMatchGame
Get a specific matchGame given its insertion order (index) in the round.- Parameters:
index
- index of the matchGame to return- Returns:
- the matchGame at the specified position in the round
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
isFinal
public boolean isFinal() -
sort
Method for sorting the matchGames in the round given a sort type, and if it should be reversed.- Parameters:
sortType
- to be sorted by.reversed
- true if yes,
-