thomasfelix

PBO 5

Nov 15th, 2020 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. /**
  4.  * Class untuk menerima inputan yang nantinya dikirimkan ke class SupportSystem.
  5.  *
  6.  * @author Thomas Felix
  7.  * @version 15 November 2020
  8.  */
  9.  
  10. public class InputReader
  11. {
  12.    private Scanner reader;
  13.    
  14.    public InputReader()
  15.    {
  16.        reader = new Scanner(System.in);
  17.    }
  18.    
  19.    public HashSet<String> getInput()
  20.    {
  21.        System.out.print("> ");
  22.        String inputLine = reader.nextLine().trim().toLowerCase();
  23.        String[] wordArray = inputLine.split(" ");
  24.        
  25.        HashSet<String> words = new HashSet<String>();
  26.        for (String word : wordArray)
  27.        {
  28.            words.add(word);
  29.        }
  30.        
  31.        return words;
  32.    }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment