gamekeeper2a
Class GameResult

java.lang.Object
  |
  +--gamekeeper2a.GameResult
All Implemented Interfaces:
IGameResult

public class GameResult
extends java.lang.Object
implements IGameResult

Information about a single, completed game.


Constructor Summary
GameResult(java.lang.String rawInfoString)
          Creates a new instance of GameResult.
GameResult(java.lang.String rawInfoString, boolean highScoreWins)
          Creates a new instance of GameResult.
GameResult(java.lang.String name1, int score1, java.lang.String name2, int score2)
          Figure out the game result, under the default assumption that high score wins.
GameResult(java.lang.String name1, int score1, java.lang.String name2, int score2, boolean highScoreWins)
          Figure out the game result.
 
Method Summary
 boolean equals(java.lang.Object otherResult)
           
 java.lang.String getLoserName()
          Tells the name of the loser of the match.
 int getLoserScore()
          Tells the score of the loser.
 java.lang.String getWinnerName()
          Tells the name of the winner of the match.
 int getWinnerScore()
          Tells the score of the winner.
 int hashCode()
           
 boolean isDraw()
          Tells if this match is a draw (true) or not (false).
static void main(java.lang.String[] args)
          Purely for testing.
 java.lang.String toString()
          Make a nice, one-line printable string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GameResult

public GameResult(java.lang.String rawInfoString)
Creates a new instance of GameResult. High score is assumed to be the winner.


GameResult

public GameResult(java.lang.String rawInfoString,
                  boolean highScoreWins)
Creates a new instance of GameResult.

Parameters:
highScoreWins - true if high score wins the game, false if low score wins.
rawInfoString - a string giving the game result. Valid strings have this format: , The two names must be different. The scores must be integers. rawInfoString is not null. If a string is invalid, the name fields are set to null and the score fields are set to 0; a better strategy would be to throw an exception. The names are trimmed of any leading or trailing spaces.

GameResult

public GameResult(java.lang.String name1,
                  int score1,
                  java.lang.String name2,
                  int score2)
Figure out the game result, under the default assumption that high score wins.


GameResult

public GameResult(java.lang.String name1,
                  int score1,
                  java.lang.String name2,
                  int score2,
                  boolean highScoreWins)
Figure out the game result.

Parameters:
highScoreWins - true if high score wins false if low score wins.
Method Detail

equals

public boolean equals(java.lang.Object otherResult)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getLoserName

public java.lang.String getLoserName()
Tells the name of the loser of the match.

Specified by:
getLoserName in interface IGameResult

getLoserScore

public int getLoserScore()
Tells the score of the loser.

Specified by:
getLoserScore in interface IGameResult

isDraw

public boolean isDraw()
Tells if this match is a draw (true) or not (false).

Specified by:
isDraw in interface IGameResult

getWinnerName

public java.lang.String getWinnerName()
Tells the name of the winner of the match. In case of a tie, this should return the 1st name of the two.

Specified by:
getWinnerName in interface IGameResult

getWinnerScore

public int getWinnerScore()
Tells the score of the winner.

Specified by:
getWinnerScore in interface IGameResult

toString

public java.lang.String toString()
Make a nice, one-line printable string.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Purely for testing.