package worldofzuul;

import java.util.Scanner;
import java.util.StringTokenizer;

/**
 * @author  Michael Kolling and David J. Barnes
 * @version 2006.03.30
 */
public class Parser {
    private CommandWords commands;
    private Scanner reader;

    public Parser() {
        commands = new CommandWords();
        reader = new Scanner(System.in);
    }

    public Command getCommand() {
        String inputLine;
        String word1 = null;
        String word2 = null;

        System.out.print("> ");

        inputLine = reader.nextLine();

        Scanner tokenizer = new Scanner(inputLine);
        if(tokenizer.hasNext()) {
            word1 = tokenizer.next();
            if(tokenizer.hasNext()) {
                word2 = tokenizer.next();
            }
        }

        return new Command(commands.getCommandWord(word1), word2);
    }

    public void showCommands() {
        commands.showAll();
    }
}

package worldofzuul;

import java.util.Scanner;


/**
 * 
 * @author ViktoriaNadarajah
 */
public class Parser {
    /**
     * It is a list of CommandWords
     */
    private CommandWords commands;
    /**
     * The Scanner reads the commands
     */
    private Scanner reader;

    /**
     * The reader reads new commands if any
     */
    public Parser() {
        commands = new CommandWords();
        reader = new Scanner(System.in);
    }
    /**
    * It reads word1 and makes a new Scanner to make a inputLine. 
    * Tokenizer is a instance variable of the type Scanner. It returns new commands
    * @return command object
    */
    public Command getCommand() {
        String inputLine;
        String word1 = null;
        String word2 = null;

        System.out.print("> ");

        inputLine = reader.nextLine();
        
        
        Scanner tokenizer = new Scanner(inputLine);
        if(tokenizer.hasNext()) {
            word1 = tokenizer.next();
            if(tokenizer.hasNext()) {
                word2 = tokenizer.next();
            }
        }

        return new Command(commands.getCommandWord(word1), word2);
    }
    /**
    * Shows all the commands
    */
    public void showCommands() {
        commands.showAll();
    }
}

add javadoc parser (#4)