mvc143
Interface IBoggleDictionaryModel


public interface IBoggleDictionaryModel

An aspect of the Model. This inferface provides the methods neccessary to manipulate the dictionary data and word history data. The interface could be implemented by the same concrete class that implements IBoggleView, or it could be a separate class. For use with the 143 Mix Matcher, a separate class would have to be inside the same compilation unit, i.e., .java file, as the main View class.


Method Summary
 void addToDictionary(String[] words)
          let the user add new words to dictionary
 void addToHistory(String acceptedProposal)
          add the accepted proposal to the history
 void emptyHistory()
          empty the history list
 List getHistory()
          get a history of all accepted words
 int getHistoryLength()
          get the length of history
 boolean isValidPosition(int row, int col)
          determine if the selected letter is permetted by geometrical constraints
 String isValidWord(String proposal)
          determine if the word proposed is valid or not.
 Set loadDictionary(URL url)
          Load a dictionary from a resource (file) specified by url.
 void saveDictionary(URL url)
          to save the dictionary to the place specified by url
 void setDictionary(Set dict)
          set the dictionary to be a given List.
 

Method Detail

loadDictionary

public Set loadDictionary(URL url)
Load a dictionary from a resource (file) specified by url.

Parameters:
url - the place to load the resource from.
Returns:
a list of words with String type; the list may be empty but should not be null.

setDictionary

public void setDictionary(Set dict)
set the dictionary to be a given List.

Parameters:
dict - set the dictionary externally.

addToDictionary

public void addToDictionary(String[] words)
let the user add new words to dictionary

Parameters:
words - an array of strings to store in dictionary

saveDictionary

public void saveDictionary(URL url)
to save the dictionary to the place specified by url

Parameters:
url - the place to store the dictionary

isValidPosition

public boolean isValidPosition(int row,
                               int col)
determine if the selected letter is permetted by geometrical constraints

Parameters:
row - specify the row of the letter selected
col - specify the column of the letter selected
Returns:
true if it is valid; otherwise false.

isValidWord

public String isValidWord(String proposal)
determine if the word proposed is valid or not.

Parameters:
proposal - a String contains the word just been selected from gui
Returns:
proposal itself, if it is valid; an error message, otherwise;

getHistory

public List getHistory()
get a history of all accepted words

Returns:
a List containing all the accepted words

getHistoryLength

public int getHistoryLength()
get the length of history

Returns:
the length of the history

emptyHistory

public void emptyHistory()
empty the history list


addToHistory

public void addToHistory(String acceptedProposal)
add the accepted proposal to the history