games.jotto.model
Class JottoModel

java.lang.Object
  extended by games.jotto.model.JottoModel
All Implemented Interfaces:
IJottoModel

public class JottoModel
extends java.lang.Object
implements IJottoModel

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.

Author:
vr28, jtl7

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

JottoModel

public JottoModel()
Method Detail

newGame

public 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.

Specified by:
newGame in interface IJottoModel
Parameters:
maxGuesses - before game is over.

addView

public void addView(IJottoGUI view)
Adds a view to this model.

Specified by:
addView in interface IJottoModel

showPopUpMessage

public 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.

Specified by:
showPopUpMessage in interface IJottoModel
Parameters:
s - is the string displayed in the modal dialog

showMessage

public void showMessage(java.lang.String s)
Display a small message in the view's message area.

Specified by:
showMessage in interface IJottoModel
Parameters:
s - is message displayed

badUserResponse

public void badUserResponse(java.lang.String s)
Display a bad response error.

Specified by:
badUserResponse in interface IJottoModel
Parameters:
s - error message

showModelResponse

public void showModelResponse(java.lang.String s)
Show model response.

Specified by:
showModelResponse in interface IJottoModel
Parameters:
s - response

initializeDictionary

public void initializeDictionary(java.util.Scanner s)
Read words and store them for guessing and validation when user guessing secret word.

Specified by:
initializeDictionary in interface IJottoModel
Parameters:
s - is scanner that is source of words

stopGame

public 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).

Specified by:
stopGame in interface IJottoModel

stopTurn

public void stopTurn()
Update Gui to end current turn and prepare for next turn

Specified by:
stopTurn in interface IJottoModel

process

public void process(java.lang.Object o)
Process input from the user. Convert input to String and feed to myGuesser

Specified by:
process in interface IJottoModel
Parameters:
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.

setHumanGuesserInputColumn

public void setHumanGuesserInputColumn()
Specified by:
setHumanGuesserInputColumn in interface IJottoModel

setComputerGuesserInputColumn

public void setComputerGuesserInputColumn()
Specified by:
setComputerGuesserInputColumn in interface IJottoModel

revealAnswer

public void revealAnswer()
Specified by:
revealAnswer in interface IJottoModel

revealHint

public void revealHint()
Specified by:
revealHint in interface IJottoModel

getStatistics

public java.lang.String getStatistics()
Specified by:
getStatistics in interface IJottoModel

clearStatistics

public void clearStatistics()
Specified by:
clearStatistics in interface IJottoModel

updateStatistics

public void updateStatistics(boolean iWon,
                             int guesses)
Specified by:
updateStatistics in interface IJottoModel