|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object AbstractPlayer
public abstract class AbstractPlayer
Supplies default implementation and state for a
player. Allows a player to a view, a scorekeeper, a lexicon
and to store words found in a game. This implementation
uses a set to store strings/words and updates score
for new words added to the player. Words are not
checked for being in a lexicon or on a board int the
add
method.
Field Summary | |
---|---|
protected ILexicon |
myLexicon
|
protected int |
myScore
|
protected BoggleScore |
myScoreKeeper
|
protected IPlayerView |
myView
|
protected java.util.TreeSet<java.lang.String> |
myWords
|
Constructor Summary | |
---|---|
AbstractPlayer()
|
Method Summary | |
---|---|
boolean |
add(java.lang.String word)
Add a word to this player's list of words, adjust score if word is new to this player. |
void |
clear()
Clear state of a player, e.g., as in a new game. |
abstract java.lang.String |
getName()
Return the name of a player. |
int |
getScore()
Return the player's score (as calculated via updates to the add method). |
void |
initialize(ILexicon lex)
Make this player have an associated lexicon and initialize other state appropriately. |
java.util.Iterator<java.lang.String> |
iterator()
|
void |
setView(IPlayerView view)
Set a veiw for this player, if not called the player will have a null view. |
int |
wordCount()
Return number of unique words added by this player. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ILexicon myLexicon
protected IPlayerView myView
protected java.util.TreeSet<java.lang.String> myWords
protected BoggleScore myScoreKeeper
protected int myScore
Constructor Detail |
---|
public AbstractPlayer()
Method Detail |
---|
public void initialize(ILexicon lex)
initialize
in interface IPlayer
lex
- is the lexicon for this playerpublic void setView(IPlayerView view)
setView
in interface IPlayer
view
- is this player's viewpublic int getScore()
add
method).
getScore
in interface IPlayer
public boolean add(java.lang.String word)
add
in interface IPlayer
word
- is the word added to this player
public java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
public abstract java.lang.String getName()
IPlayer
getName
in interface IPlayer
public void clear()
IPlayer
clear
in interface IPlayer
public int wordCount()
IPlayer
wordCount
in interface IPlayer
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |