public Command getUserCommand(String s) { String word1 = null; String word2 = null; // Find up to two words on the line. StringTokenizer tokenizer = new StringTokenizer(s); if (tokenizer.hasMoreTokens()) { word1 = tokenizer.nextToken(); // get first word if (tokenizer.hasMoreTokens()) { word2 = tokenizer.nextToken(); // get second word // note: we just ignore the rest of the input line. } } return new Command(commands.getCommandWord(word1), word2); }