Class DictionaryManager

java.lang.Object
model.logic.server.dictionary.DictionaryManager

public class DictionaryManager extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    challenge(String... args)
    The challenge function takes in a String array of words and returns true if any of the words are anagrams of the last word.
    get()
    The get function is a static function that returns the singleton instance of the DictionaryManager class.
    int
    The getSize function returns the size of the map.
    boolean
    query(String... args)
    The query function takes in a String array of arguments and returns a boolean.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static DictionaryManager get()
      The get function is a static function that returns the singleton instance of the DictionaryManager class. If no instance exists, it creates one and then returns it.
      Returns:
      The singleton instance of the dictionary manager
    • query

      public boolean query(String... args)
      The query function takes in a String array of arguments and returns a boolean. The last argument is the word to be searched for, while the rest are dictionaries that will be searched through. If any of the dictionaries contain the word, then true is returned; otherwise false is returned. This function also adds new entries to map if they do not already exist there (i.e., if an entry does not exist in map, it will create one).
      Parameters:
      args - args Pass in a variable number of arguments
      Returns:
      True if the word is found in any of the dictionaries,
    • challenge

      public boolean challenge(String... args)
      The challenge function takes in a String array of words and returns true if any of the words are anagrams of the last word. It does this by iterating through each word in the array, excluding the last one, and checking to see if it is an anagram using its challenge function.
      Parameters:
      args - args Pass in a variable number of arguments
      Returns:
      True if any of the words in args are a valid
    • getSize

      public int getSize()
      The getSize function returns the size of the map.
      Returns:
      The size of the map