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

public class Match extends Object implements Serializable
Class that holds a Match. A match is defined as a match played against an opponent and the scores of the opponent and the player that holds the match
See Also:
  • Constructor Details

    • Match

      public Match(Player opponent, int opponentScore, int playerScore)
      Constructor for creating an instance for a match between two players
      Parameters:
      opponent - the Player opponent
      opponentScore - the opponent's score as an int
      playerScore - the Player's score as an int
    • Match

      public Match(Player opponent)
      Sets scores to be -1 which means they have not been played yet
      Parameters:
      opponent -
  • Method Details

    • getMatchResult

      public int getMatchResult()
      Method to determine whether the player has won, drew, or lost the game
      Returns:
      1 if the player won, 0 if draw between player and opponent occurs, -1 if player loses
    • getOpponent

      public Player getOpponent()
    • getOpponentScore

      public int getOpponentScore()
    • setOpponentScore

      public void setOpponentScore(int opponentScore)
      Sets the score of the opponent
      Parameters:
      opponentScore - score of the opponent, can not be less than zero
      Throws:
      IllegalArgumentException - if score is less than zero.
    • getPlayerScore

      public int getPlayerScore()
    • setPlayerScore

      public void setPlayerScore(int playerScore)
      Sets the score of the player that holds the match
      Parameters:
      playerScore - score of the opponent, can not be less than zero
      Throws:
      IllegalArgumentException - if score is less than zero.