Class MatchRound

java.lang.Object
edu.ntnu.idatt1002.k2g05.models.rounds.Round
edu.ntnu.idatt1002.k2g05.models.rounds.MatchRound
All Implemented Interfaces:
Serializable

public class MatchRound extends Round
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

    Constructors
    Constructor
    Description
    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 Type
    Method
    Description
    boolean
    Method for adding matchGame to the round.
    void
    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 round
    getMatchGame(int index)
    Get a specific matchGame given its insertion order (index) in the round.
    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
     
    boolean
    Removes the first occurrence of a matchGame from this round, if it is present.
    void
    sort(SortType sortType)
    Method for sorting the matchGames in the round given a sort type
    void
    sort(SortType sortType, boolean reversed)
    Method for sorting the matchGames in the round given a sort type, and if it should be reversed.

    Methods inherited from class edu.ntnu.idatt1002.k2g05.models.rounds.Round

    getName, setName, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MatchRound

      public MatchRound(String name)
      Constructor for making an instance of a MatchRound. Given the name. isFinal will be set to false.
      Parameters:
      name - of the round
    • MatchRound

      public MatchRound(String name, boolean isFinal)
      Constructor for making an instance of a MatchRound. Given the name and if it is a final
      Parameters:
      name - of the round
      isFinal - true if yes.
  • Method Details

    • clear

      public void clear()
      Description copied from class: Round
      Method for clearing the round of games.
      Specified by:
      clear in class Round
    • addMatchGame

      public boolean addMatchGame(MatchGame matchGame)
      Method for adding matchGame to the round.
      Parameters:
      matchGame - to be added ot the list
      Returns:
      true (as specified by Collection.add(E))
      Throws:
      NullPointerException - if the specified matchGame is null
    • getTopMatchGames

      public List<MatchGame> 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.
      Parameters:
      n - amount of top players to get
      Returns:
      n top players
    • removeMatchGame

      public boolean removeMatchGame(MatchGame matchGame)
      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. Returns true 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

      public void sort(SortType sortType)
      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

      public List<MatchGame> getAllMatchGames()
      Method for getting all the matchGames in the round.
      Returns:
      all the match games
    • getMatchGame

      public MatchGame getMatchGame(int index)
      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

      public void sort(SortType sortType, boolean reversed)
      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,