Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 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 main(String[] args){
  15. System.out.println("Welcome to the test console!");
  16. readConsole();
  17. }
  18.  
  19. public static void readConsole(){
  20. while(true){
  21. @SuppressWarnings("resource")
  22. Scanner scan = new Scanner(System.in);
  23. String input = scan.nextLine();
  24. String[] splitInput;
  25. try {
  26. splitInput = input.split("\\s+");
  27. if(splitInput[0].equals("start")){
  28. if(splitInput.length == 5){
  29. //set variables
  30. username = splitInput[1];
  31. password = splitInput[2];
  32. activityId = splitInput[3];
  33. problemId = splitInput[4];
  34. System.out.println("starting program...");
  35. //start program here
  36. System.out.println("back to console");
  37. }else{
  38. System.out.println("start <username> <password> <activity-id> <problem-id>");
  39. }
  40. }else if(splitInput[0].equals("help")){
  41. System.out.println("Commands:");
  42. System.out.println("start <username> <password> <activity-id> <problem-id>");
  43. }else{
  44. System.out.println("invalid input try 'help' for list of commands");
  45. }
  46. } catch (PatternSyntaxException ex) {
  47. System.out.println("invalid input try 'help' for list of commands");
  48. }
  49. }
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement