Class QualificationRound

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

public class QualificationRound extends Round
Round where each player plays an amount given amount of Game, and an accumulative sum of all rounds are created.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for creating an instance of the given class.
    QualificationRound(String name, int playsPerPlayer)
    Constructor for creating an instance of the class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addGame(Game game)
    Method for adding game to the round.
    void
    Method for clearing the round of games.
    Method for getting all the games in the round
    Method for getting a Game given the player that has played it.
    getGamesByNameSearch(String search, int threshold)
    Method for returning a list over results given a search query by name.
    int
     
    getTopGames(int n)
    Method for getting the top n games in the round, "top" is defined by the sum that the game 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
    Removes the first occurrence of a game from this round, if it is present.
    void
    sort(SortType sortType)
    Method for sorting the games in the round given a sort type
    void
    sort(SortType sortType, boolean reversed)
    Method for sorting the games 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

    • QualificationRound

      public QualificationRound(String name)
      Constructor for creating an instance of the given class. Plays per player will be defaulted to 6.
      Parameters:
      name - of the round, can not be null
    • QualificationRound

      public QualificationRound(String name, int playsPerPlayer)
      Constructor for creating an instance of the class.
      Parameters:
      name - of the round.
      playsPerPlayer - amount of games a player is going to play.
  • Method Details

    • addGame

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

      public boolean removeGame(Game game)
      Removes the first occurrence of a game from this round, if it is present. If this round does not contain the game, it is unchanged. Returns true if this list contained the specified game (or equivalently, if this round changed as a result of the call).
      Parameters:
      game - to be removed
      Returns:
      true if this round contained the specified game
    • getAllGames

      public List<Game> getAllGames()
      Method for getting all the games in the round
      Returns:
    • getGamesByNameSearch

      public List<Game> getGamesByNameSearch(String search, int threshold)
      Method for returning a list over results given a search query by name. A fuzzy search algorithm is used so the user does not have to write the exact player name.
      Parameters:
      search - to be filtered by
      threshold - of the fuzzy search, the higher the value the more specific a search has to be. Threshold must be between 0 and 100
      Returns:
      the results of the search.
    • getGameByPlayer

      public Game getGameByPlayer(Player player)
      Method for getting a Game given the player that has played it.
      Parameters:
      player -
      Returns:
    • getTopGames

      public List<Game> getTopGames(int n)
      Method for getting the top n games in the round, "top" is defined by the sum that the game 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
    • getPlaysPerPlayer

      public int getPlaysPerPlayer()
    • sort

      public void sort(SortType sortType)
      Method for sorting the games in the round given a sort type
      Parameters:
      sortType - to sort by.
    • sort

      public void sort(SortType sortType, boolean reversed)
      Method for sorting the games in the round given a sort type, and if it should be reversed.
      Parameters:
      sortType - to be sorted by.
      reversed - true if yes,
    • clear

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