Advertisement
trizehn

InputReader

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