com.anji.tournament
Class SimpleTournament

java.lang.Object
  extended by com.anji.tournament.SimpleTournament
All Implemented Interfaces:
Tournament, Configurable
Direct Known Subclasses:
DirectTournament, KRandomOppsTournament

public abstract class SimpleTournament
extends java.lang.Object
implements Tournament, Configurable

Abstract class that manages a list of Player contestants, has them play each other in matches, and packages the results.

Author:
Philip Tucker

Nested Class Summary
protected  class SimpleTournament.PlayerPair
          Pair of PlayerAndResults for each game.
 
Field Summary
static java.lang.String COMPONENT_GAME_KEY
          component game
 
Constructor Summary
  SimpleTournament()
          default ctor; should be followwed by init()
protected SimpleTournament(Game aGame, ScoringWeights aWeights)
           
 
Method Summary
 void addContestant(Player player)
           
 void clearContestants()
          remove all contestants added via addContestant()
protected abstract  void endTournament()
          end tournament
protected  Game getGame()
           
protected  java.util.List getResults()
          Returns all players added via addContestant() thus far and associated results.
protected  ScoringWeights getScoringWeights()
           
protected abstract  boolean hasNextPlayerPair()
           
 void init(Properties props)
           
protected abstract  SimpleTournament.PlayerPair nextPlayerPair()
           
protected  void playMatch(SimpleTournament.PlayerPair pair)
           
 java.util.List playTournament()
          Play full tournament.
protected abstract  void startTournament()
          restart tournament
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.anji.tournament.Tournament
getMaxScore, getMinScore
 

Field Detail

COMPONENT_GAME_KEY

public static final java.lang.String COMPONENT_GAME_KEY
component game

See Also:
Constant Field Values
Constructor Detail

SimpleTournament

protected SimpleTournament(Game aGame,
                           ScoringWeights aWeights)
Parameters:
aGame -
aWeights -

SimpleTournament

public SimpleTournament()
default ctor; should be followwed by init()

Method Detail

init

public void init(Properties props)
          throws java.lang.Exception
Specified by:
init in interface Configurable
Parameters:
props -
Throws:
java.lang.Exception

clearContestants

public void clearContestants()
Description copied from interface: Tournament
remove all contestants added via addContestant()

Specified by:
clearContestants in interface Tournament
See Also:
Tournament.clearContestants()

addContestant

public void addContestant(Player player)
Specified by:
addContestant in interface Tournament
Parameters:
player - Player to be added.

getResults

protected java.util.List getResults()
Returns all players added via addContestant() thus far and associated results.

Returns:
List contains PlayerAndResults objects

playTournament

public java.util.List playTournament()
Description copied from interface: Tournament
Play full tournament.

Specified by:
playTournament in interface Tournament
Returns:
List contains TournamentPlayerResults objects, sorted in descending order of score
See Also:
Tournament.playTournament()

playMatch

protected void playMatch(SimpleTournament.PlayerPair pair)
Parameters:
pair -

startTournament

protected abstract void startTournament()
restart tournament


endTournament

protected abstract void endTournament()
end tournament


nextPlayerPair

protected abstract SimpleTournament.PlayerPair nextPlayerPair()
Returns:
next pair of players

hasNextPlayerPair

protected abstract boolean hasNextPlayerPair()
Returns:
boolean true if player pairs are stil available

getScoringWeights

protected ScoringWeights getScoringWeights()
Returns:
scoring weights

getGame

protected Game getGame()
Returns:
game object