Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myPart;
- import java.util.Scanner;
- import java.util.regex.PatternSyntaxException;
- public class ConsoleStuff {
- static String username;
- static String password;
- static String activityId;
- static String problemId;
- public static void readConsole(){
- @SuppressWarnings("resource")
- Scanner scan = new Scanner(System.in);
- String input = scan.nextLine();
- String[] splitInput;
- try {
- splitInput = input.split("\\s+");
- if(splitInput[0].equals("start")){
- if(splitInput.length == 5){
- //set variables
- username = splitInput[1];
- password = splitInput[2];
- activityId = splitInput[3];
- problemId = splitInput[4];
- //start program here
- }else{
- System.out.println("start <username> <password> <activity-id> <problem-id>");
- }
- }else if(splitInput[0].equals("help")){
- System.out.println("Commands:");
- System.out.println("start <username> <password> <activity-id> <problem-id>");
- }else{
- System.out.println("invalid input try 'help' for list of commands");
- }
- } catch (PatternSyntaxException ex) {
- System.out.println("invalid input try 'help' for list of commands");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement