コード例 #1
0
ファイル: prog3.java プロジェクト: theraptor42/CS-102
  /*
  Method: removeEntry  - basic user interface
  Purpose: word menu, interacts with user and calls database methods
              to remove entries
              real work is done in database
  Parameters:
      Database currentThesaurus   the database parsed from the text file
  Returns:
      none
  */
  public static void removeEntry(Database currentThesaurus) {
    System.out.println("\nPlease type the word you would like to remove");
    System.out.print(">>");
    // Will accept spaces in words
    // Scanner to take user input
    Scanner inputScanner = new Scanner(System.in);
    // the wood the user wants to add
    String newUserWord = inputScanner.nextLine();

    // checks whether the word was added successfully
    boolean successCheck = currentThesaurus.removeEntryFromMenu(newUserWord);
    if (successCheck) {
      System.out.println("\n" + newUserWord + " has been " + "removed from the thesaurus");
      System.out.println("\nGoing back to the main menu");
    } else {
      System.out.println("Going back to the main menu");
      // returns to the main menu
    }
  }