|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAbstractPlayer
public abstract class AbstractPlayer
Supplies default implementation and state for a player. Allows a player to access a model, a view, 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.
Field Summary | |
---|---|
protected BoggleModel |
myModel
|
protected int |
myScore
|
protected IPlayerView |
myView
|
protected java.util.TreeSet<java.lang.String> |
myWords
|
Constructor Summary | |
---|---|
AbstractPlayer()
|
Method Summary | |
---|---|
void |
add(java.lang.String word)
Add a word to this player's list of words, adjust score if word is new to this player. |
abstract java.lang.String |
getName()
Return the name of a player. |
int |
getScore()
Get the score for this player, see BoggleModel
for how scores are calculated. |
void |
initialize(BoggleModel model)
Make this player have an associated model, and initialize other state appropriately. |
void |
setView(IPlayerView view)
Set a veiw for this player, if not called the player will have a null view. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected BoggleModel myModel
protected IPlayerView myView
protected java.util.TreeSet<java.lang.String> myWords
protected int myScore
Constructor Detail |
---|
public AbstractPlayer()
Method Detail |
---|
public void initialize(BoggleModel model)
initialize
in interface IPlayer
model
- is the model for this playerpublic void setView(IPlayerView view)
setView
in interface IPlayer
view
- is this player's viewpublic int getScore()
IPlayer
BoggleModel
for how scores are calculated.
getScore
in interface IPlayer
public void add(java.lang.String word)
add
in interface IPlayer
word
- is the word added to this playerpublic abstract java.lang.String getName()
IPlayer
getName
in interface IPlayer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |