|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgames.jotto.model.JottoModel
public class JottoModel
This is the Jotto model.
This class keeps words and a status-flag indicating whether human or computer
is guessing.
The view communicates with this class: The method newGame
clears
state so that the computer can begin to guess the user's word (i.e., when
myModelGuesses == true) or the computer picks a secret word that the
human-user tries to guess.
Constructor Summary | |
---|---|
JottoModel()
|
Method Summary | |
---|---|
void |
addView(IJottoGUI view)
Adds a view to this model. |
void |
badUserResponse(java.lang.String s)
Display a bad response error. |
void |
clearStatistics()
|
java.lang.String |
getStatistics()
|
void |
initializeDictionary(java.util.Scanner s)
Read words and store them for guessing and validation when user guessing secret word. |
void |
newGame(int maxGuesses,
java.lang.String className)
Start a new game with maximal number of guesses as specified which indicates the number of guesses before the game is over. |
void |
process(java.lang.Object o)
Process input from the user. |
void |
revealAnswer()
|
void |
revealHint()
|
void |
setComputerGuesserInputColumn()
|
void |
setHumanGuesserInputColumn()
|
void |
showMessage(java.lang.String s)
Display a small message in the view's message area. |
void |
showModelResponse(java.lang.String s)
Show model response. |
void |
showPopUpMessage(java.lang.String s)
Display a dialog box the user must dismiss as part of the view, e.g., when the game is over. |
void |
stopGame(java.lang.String popUp,
java.lang.String msg)
Make the view not respond to user input except by choosing new game or quit (call view method that disables user input). |
void |
stopTurn()
Update Gui to end current turn and prepare for next turn |
void |
updateStatistics(boolean iWon,
int guesses)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JottoModel()
Method Detail |
---|
public void newGame(int maxGuesses, java.lang.String className)
newGame
in interface IJottoModel
maxGuesses
- before game is over.public void addView(IJottoGUI view)
addView
in interface IJottoModel
public void showPopUpMessage(java.lang.String s)
showPopUpMessage
in interface IJottoModel
s
- is the string displayed in the modal dialogpublic void showMessage(java.lang.String s)
showMessage
in interface IJottoModel
s
- is message displayedpublic void badUserResponse(java.lang.String s)
badUserResponse
in interface IJottoModel
s
- error messagepublic void showModelResponse(java.lang.String s)
showModelResponse
in interface IJottoModel
s
- responsepublic void initializeDictionary(java.util.Scanner s)
initializeDictionary
in interface IJottoModel
s
- is scanner that is source of wordspublic void stopGame(java.lang.String popUp, java.lang.String msg)
stopGame
in interface IJottoModel
public void stopTurn()
stopTurn
in interface IJottoModel
public void process(java.lang.Object o)
process
in interface IJottoModel
o
- is the response from the user. It's a string and either a five
letter word or a String representing an int that's the number
of letters in common with last word guessed by computer.public void setHumanGuesserInputColumn()
setHumanGuesserInputColumn
in interface IJottoModel
public void setComputerGuesserInputColumn()
setComputerGuesserInputColumn
in interface IJottoModel
public void revealAnswer()
revealAnswer
in interface IJottoModel
public void revealHint()
revealHint
in interface IJottoModel
public java.lang.String getStatistics()
getStatistics
in interface IJottoModel
public void clearStatistics()
clearStatistics
in interface IJottoModel
public void updateStatistics(boolean iWon, int guesses)
updateStatistics
in interface IJottoModel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |