Class MatchGame
java.lang.Object
edu.ntnu.idatt1002.k2g05.models.games.MatchGame
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Appends the specified match to the end of the matchGame's list.void
clear()
Method for clearing all the matches played.int
getDraw()
Method for getting the amount matches that is a drawint
getLost()
Method for getting the amount matches that is lostint
int
Gets the points that a player has gotten accross its matches.int
getWon()
Method for getting the amount matches that is a winboolean
removeMatch
(Match match) Removes the first occurrence of a match from this matchGame, if it is present.toString()
-
Constructor Details
-
MatchGame
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
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 byCollection.add(E)
)- Throws:
NullPointerException
- if the specified match is null
-
removeMatch
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. Returnstrue
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
-
getPlayer
-
toString
-
clear
public void clear()Method for clearing all the matches played.
-