Esempio n. 1
0
  /*
  Method: synonymSearchMenu - user interface
  Purpose: word menu, interacts with user and calls database methods
              to search for user input, prints out search results
  Parameters:
      Database currentThesaurus   the database parsed from the text file
  Returns:
      none
  */
  public static void synonymSearchMenu(Database currentThesaurus) {
    // basic menu for simple text input
    // should work for any normal circumstances
    // because it stores user input into a string
    System.out.println("\nPlease type the synonym to be searched for");
    System.out.print(">> ");
    // Scanner to take user input
    Scanner inputScanner = new Scanner(System.in);
    // Synonym being searched for
    String userInput = inputScanner.nextLine();

    // searches each entry for a matching synonym
    String returnString = currentThesaurus.searchForSynonym(userInput);
    // the results of the search
    System.out.println(returnString + "\n");
  }