Advertisement
Guest User

UserInterface

a guest
Apr 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.util.Scanner;
  3.  
  4. public class User_Interface {
  5.     static Dictionary myDictionary = new Dictionary();
  6.  
  7.     public static void main(String[] args) throws IOException {
  8.         System.out.println( "|**************************************************************************|" );
  9.         System.out.println( "|                               Dictionary                                 |" );
  10.         System.out.println( "|**************************************************************************|" );
  11.         System.out.println( "| load:   Load 'dictionary.txt'        size:    Dictionary Size            |" );
  12.         System.out.println( "| insert: Insert a Single Word         remove:  Remove a Single Word       |" );
  13.         System.out.println( "| lookup: Search for a Single Word     Blookup: Search for a Batch of Words|" );
  14.         System.out.println( "| Bremove:  Remove a Batch of Words    exit: Exit Program                  |" );
  15.         System.out.println( "|**************************************************************************|" );
  16.         while (SwitchCase()){}
  17.         System.out.println( "****************************************************************************" );
  18.         System.exit(0);
  19.     }
  20.    
  21.     private static boolean SwitchCase() throws IOException{
  22.         System.out.println( "\nEnter a Keyword: " );
  23.         Scanner scanner = new Scanner(System.in);
  24.         String keyword = scanner. nextLine();
  25.        
  26.         if( keyword.equals("exit") )
  27.             return false;
  28.         else if( keyword.equals("load") )
  29.             myDictionary.loadDictionary();
  30.         else if( keyword.equals("size") )
  31.             myDictionary.printSize();
  32.         else if( keyword.equals("insert") ){
  33.             System.out.println( "Enter a new Word: " );
  34.             myDictionary.insertWord();
  35.         }
  36.         else if( keyword.equals("remove") ){
  37.             System.out.println( "Enter a Word to Remove: " );
  38.             myDictionary.RemoveWord();
  39.         }
  40.         else if( keyword.equals("lookup") ){
  41.             System.out.println( "Enter a Word to Search for: " );
  42.             myDictionary.LookWord();
  43.         }
  44.         else if( keyword.equals("Blookup") )
  45.             myDictionary.BatchLook();
  46.         else if( keyword.equals("Bremove") )
  47.             myDictionary.BatchDeletions();
  48.        
  49.         else{
  50.             System.out.println( "Invalid Keyword \n " );
  51.         }
  52.        
  53.         return true;
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement