com.toy.anagrams.lib
Class WordLibrary

java.lang.Object
  extended by com.toy.anagrams.lib.WordLibrary

public abstract class WordLibrary
extends java.lang.Object

Interface defining logic for the Anagram Game application.


Constructor Summary
protected WordLibrary()
          Constructor for subclasses.
 
Method Summary
static WordLibrary getDefault()
          Getter for the default implementation of the WordLibrary.
abstract  java.lang.String getScrambledWord(int idx)
          Gets the word at a given index in its scrambled form.
abstract  int getSize()
          Gets the number of words in the library.
abstract  java.lang.String getWord(int idx)
          Gets the word at a given index.
abstract  boolean isCorrect(int idx, java.lang.String userGuess)
          Checks whether a user's guess for a word at the given index is correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordLibrary

protected WordLibrary()
Constructor for subclasses.

Method Detail

getDefault

public static WordLibrary getDefault()
Getter for the default implementation of the WordLibrary.

Returns:
some default implementation of WordLibrary

getWord

public abstract java.lang.String getWord(int idx)
Gets the word at a given index.

Parameters:
idx - index of required word
Returns:
word at that index in its natural form

getScrambledWord

public abstract java.lang.String getScrambledWord(int idx)
Gets the word at a given index in its scrambled form.

Parameters:
idx - index of required word
Returns:
word at that index in its scrambled form

getSize

public abstract int getSize()
Gets the number of words in the library.

Returns:
the total number of plain/scrambled word pairs in the library

isCorrect

public abstract boolean isCorrect(int idx,
                                  java.lang.String userGuess)
Checks whether a user's guess for a word at the given index is correct.

Parameters:
idx - index of the word guessed
userGuess - the user's guess for the actual word
Returns:
true if the guess was correct; false otherwise