Class MatchGame

java.lang.Object
edu.ntnu.idatt1002.k2g05.models.games.MatchGame
All Implemented Interfaces:
Serializable

public class MatchGame extends Object implements Serializable
A match game holds a player and all of his matches against other people. This will create duplicates, e.g if player "A" plays a match against player "B", "B" has also played a match against player "A". The reason for storing the data this way is that it makes it a lot easier to fin the amount of points a player has earned. But in hindsight, it would probably be better to not store duplicates because the front-end application is going to have to manage the duplicates.
See Also:
  • Constructor Details

    • MatchGame

      public MatchGame(Player player)
      Constructor for creating an instance of the game, given the player that plays it.
      Parameters:
      player -
  • Method Details

    • getPoints

      public int getPoints()
      Gets the points that a player has gotten accross its matches. The amount of points rewarded for winning, drawing and losing is determined by the constants of the class.
      Returns:
      the points
    • getWon

      public int getWon()
      Method for getting the amount matches that is a win
      Returns:
      number of wins
    • getLost

      public int getLost()
      Method for getting the amount matches that is lost
      Returns:
      number lost
    • getDraw

      public int getDraw()
      Method for getting the amount matches that is a draw
      Returns:
      number of draws
    • getPlayed

      public int getPlayed()
    • addMatch

      public boolean addMatch(Match match)
      Appends the specified match to the end of the matchGame's list. null is prohibited.
      Parameters:
      match - element to be appended to this list
      Returns:
      true (as specified by Collection.add(E))
      Throws:
      NullPointerException - if the specified match is null
    • removeMatch

      public boolean removeMatch(Match match)
      Removes the first occurrence of a match from this matchGame, if it is present. If this matchGame does not contain the match, it is unchanged. Returns true if this list contained the specified match (or equivalently, if this list changed as a result of the call).
      Parameters:
      match - match to be removed from this tournament, if present
      Returns:
      true if this list contained the specified match.
    • getAllMatches

      public List<Match> getAllMatches()
    • getPlayer

      public Player getPlayer()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clear

      public void clear()
      Method for clearing all the matches played.