kuchuz

PBO-C 5 : InputReader()

Nov 26th, 2020
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class InputReader
  4. {
  5.     private Scanner reader;
  6.      
  7.     public InputReader()
  8.     {
  9.         reader = new Scanner(System.in);
  10.     }
  11.      
  12.     public HashSet<String> getInput()
  13.     {
  14.         System.out.println("> ");
  15.         String inputLine = reader.nextLine().trim().toLowerCase();
  16.         String[] wordArray = inputLine.split(" ");
  17.         HashSet<String> words = new HashSet<String>();
  18.        
  19.         for(String word: wordArray)
  20.         {
  21.             words.add(word);
  22.         }
  23.        
  24.         return words;
  25.     }
  26. }
RAW Paste Data