Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package myPart;
  2.  
  3. import java.util.Scanner;
  4. import java.util.regex.PatternSyntaxException;
  5.  
  6. public class ConsoleStuff {
  7.  
  8.  
  9. static String username;
  10. static String password;
  11. static String activityId;
  12. static String problemId;
  13.  
  14. public static void readConsole(){
  15. @SuppressWarnings("resource")
  16. Scanner scan = new Scanner(System.in);
  17. String input = scan.nextLine();
  18. String[] splitInput;
  19. try {
  20. splitInput = input.split("\\s+");
  21. if(splitInput[0].equals("start")){
  22. if(splitInput.length == 5){
  23. //set variables
  24. username = splitInput[1];
  25. password = splitInput[2];
  26. activityId = splitInput[3];
  27. problemId = splitInput[4];
  28. //start program here
  29. }else{
  30. System.out.println("start <username> <password> <activity-id> <problem-id>");
  31. }
  32. }else if(splitInput[0].equals("help")){
  33. System.out.println("Commands:");
  34. System.out.println("start <username> <password> <activity-id> <problem-id>");
  35. }else{
  36. System.out.println("invalid input try 'help' for list of commands");
  37. }
  38. } catch (PatternSyntaxException ex) {
  39. System.out.println("invalid input try 'help' for list of commands");
  40. }
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement