Class Match
java.lang.Object
edu.ntnu.idatt1002.k2g05.models.games.Match
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Method to determine whether the player has won, drew, or lost the gameint
int
void
setOpponentScore
(int opponentScore) Sets the score of the opponentvoid
setPlayerScore
(int playerScore) Sets the score of the player that holds the match
-
Constructor Details
-
Match
Constructor for creating an instance for a match between two players- Parameters:
opponent
- the Player opponentopponentScore
- the opponent's score as an intplayerScore
- the Player's score as an int
-
Match
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
-
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.
-