gamekeeper2a
Class Contestant

java.lang.Object
  |
  +--gamekeeper2a.Contestant
All Implemented Interfaces:
IContestant

public class Contestant
extends java.lang.Object
implements IContestant

Information about a single contestant. Unless the subclass specifies otherwise, assume that contestant names are case sensitive; and that leading and trailing spaces (but not internal spaces) are ignored and trimmed.


Constructor Summary
Contestant(java.lang.String contestant)
          Creates a new instance of contestant, with initial no games recorded.
 
Method Summary
 int getGamesDrawn()
          Tells the number of games tied (draws) so far.
 int getGamesLost()
          Tells the number of games lost so far.
 int getGamesWon()
          Tells the number of games won so far.
 java.lang.String getName()
          Tells the name of this contestant.
 double getWinRatio()
          Return a number which summarizes how well the contestant has done so far.
 void recordDraw()
          Remember that a game was a draw.
 void recordLoss()
          Remember that a game was lost.
 void recordWin()
          Remember that a game was won.
 java.lang.String toString()
          Format a string, without line feeds or surrounding whitespace, with basic contestant information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Contestant

public Contestant(java.lang.String contestant)
Creates a new instance of contestant, with initial no games recorded.

Method Detail

getGamesLost

public int getGamesLost()
Description copied from interface: IContestant
Tells the number of games lost so far.

Specified by:
getGamesLost in interface IContestant

getGamesWon

public int getGamesWon()
Description copied from interface: IContestant
Tells the number of games won so far.

Specified by:
getGamesWon in interface IContestant

getGamesDrawn

public int getGamesDrawn()
Description copied from interface: IContestant
Tells the number of games tied (draws) so far. For some types of games, this will always be zero.

Specified by:
getGamesDrawn in interface IContestant

getName

public java.lang.String getName()
Tells the name of this contestant. Spaces are trimmed.

Specified by:
getName in interface IContestant

recordLoss

public void recordLoss()
Remember that a game was lost.

Specified by:
recordLoss in interface IContestant

recordWin

public void recordWin()
Remember that a game was won.

Specified by:
recordWin in interface IContestant

recordDraw

public void recordDraw()
Description copied from interface: IContestant
Remember that a game was a draw.

Specified by:
recordDraw in interface IContestant

getWinRatio

public double getWinRatio()
Return a number which summarizes how well the contestant has done so far. Higher values are considered better.

Returns:
games won /(games lost + games drawn). If no games have been played, return 0.0.

toString

public java.lang.String toString()
Format a string, without line feeds or surrounding whitespace, with basic contestant information.

Overrides:
toString in class java.lang.Object