Advertisement
lamaulfarid

InputReader

Nov 11th, 2020
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.HashSet;
  2. import java.util.Scanner;
  3. import java.util.Random;
  4. import java.util.ArrayList;
  5. import java.util.HashSet;
  6.  
  7. /**
  8.  * The InputReader class is used for read the input entry.
  9.  *
  10.  * @author Ahmad Lamaul Farid
  11.  * @version 12 November 2020
  12.  */
  13. public class InputReader
  14. {
  15.     private Scanner reader;
  16.     public InputReader()
  17.     {
  18.         reader = new Scanner(System.in);
  19.     }
  20.     /**
  21.      * Read user input
  22.      */
  23.     public HashSet<String> getInput()
  24.     {
  25.         System.out.print(">>   ");
  26.         String inputLine = reader.nextLine().trim().toLowerCase();
  27.        
  28.         String[] wordArray = inputLine.split(" ");
  29.        
  30.         HashSet<String> words = new HashSet<String>();
  31.         for(String word : wordArray)
  32.         {
  33.             words.add(word);
  34.         }
  35.         return words;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement