/**
 * Command class.
 * 
 * @author  Ryan Seys
 */

public class Command
{
    private CommandWords firstWord;
    private Object secondWord;

    /**
     * Create a command object. First and second word must be supplied, but
     * either one (or both) can be null.
     * @param firstWord The first word of the command. Null if the command
     *                  was not recognised.
     * @param secondWord The second word of the command.
     */
    public Command(CommandWords firstWord, Object secondWord)
    {
        this.firstWord = firstWord;
        this.secondWord = secondWord;
    }

    /**
     * Return the command word (the first word) of this command. If the
     * command was not understood, the result is null.
     * @return The command word.
     */
    public CommandWords getFirstWord()
    {
        return firstWord;
    }
    
    /**
     * Return the command word (the first word) of this command. If the
     * command was not understood, the result is null.
     * @return The command word.
     */
    public CommandWords getCommandWord()
    {
        return firstWord; //basically the same as getFirstWord
    }

    /**
     * @return The second word of this command. Returns null if there was no
     * second word.
     */
    public Object getSecondWord()
    {
        return secondWord;
    }

    /**
     * @return true if this command was not understood.
     */
    public boolean isUnknown()
    {
        return (firstWord == null);
    }
    
    /**
     * @return whether the command is undoable
     */
    public boolean isUndoable() {
    	return true; // TODO: implement this
    }
    
    /**
     * @return true if the command has a second word.
     */
    public boolean hasSecondWord()
    {
        return (secondWord != null);
    }
    
    public Command getOpposite() {
    	if(firstWord == CommandWords.FIGHT ||
    		firstWord == CommandWords.HELP ||
    		firstWord == CommandWords.QUIT) {
    		return null;
    	}
    	else {
    		if(firstWord == CommandWords.GO) {
    			return new Command(CommandWords.GO, ((Direction) secondWord).getOpposite());
    		}
    		else if(firstWord == CommandWords.PICKUP) {
    			return new Command(CommandWords.DROP, secondWord);
    		}
    		else if(firstWord == CommandWords.DROP) {
    			return new Command(CommandWords.PICKUP, secondWord);
    		}
    	return null;
    	}
    }
}


@@ -1595,44 +1595,205 @@
    %09
-return true; // TODO: implement this
+if(firstWord == CommandWords.FIGHT %7C%7C%0A        %09%09firstWord == CommandWords.HELP %7C%7C%0A        %09%09firstWord == CommandWords.QUIT) %7B%0A        %09%09return false;%0A        %7D%0A    %09else %7B%0A    %09%09return true;%0A    %09%7D
 %0A   
@@ -2006,119 +2006,21 @@
 %09if(
-firstWord == CommandWords.FIGHT %7C%7C%0A    %09%09firstWord == CommandWords.HELP %7C%7C%0A    %09%09firstWord == CommandWords.QUIT
+!isUndoable()
 ) %7B%0A
@@ -2432,32 +2432,32 @@
   %09return null;%0A
-
     %09%7D%0A    %7D%0A%7D%0A%0A
@@ -2453,11 +2453,1102 @@
 %7D%0A    %7D%0A
+    %0A    public static Command parse(String command) %7B%0A    %09if(command == %22%22 %7C%7C command == null) return null;%0A    %09command = command.toLowerCase().trim();%0A    %09String%5B%5D commands = command.split(%22 %22);%0A    %09String first = commands%5B0%5D;%0A    %09String second = commands%5B1%5D;%0A    %09CommandWords cmdword = CommandWords.valueOf(first); //get the first word for the command%0A    %09if(cmdword != null) %7B%0A%09    %09if(second == null ) %7B%0A%09    %09%09return new Command(cmdword, null);%0A%09    %09%7D%0A%09    %09else %7B%0A%09    %09%09if(cmdword == CommandWords.GO) %7B%0A%09    %09%09%09Direction dir = Direction.valueOf(second); //get direction%0A%09    %09%09%09if(dir != null) return new Command(cmdword, dir);%0A%09    %09%09%7D%0A%09    %09%09else if (cmdword == CommandWords.DROP %7C%7C cmdword == CommandWords.PICKUP) %7B%0A%09    %09%09%09//TODO:%0A%09    %09%09%09//command for picking up an item, right now misunderstood because you cannot have reference to an item in the string.%0A%09    %09%09%09//must know about player or room or something, doesn't seem correct.%0A%09    %09%09%09//shouldn't make a new item because we know nothing else about it (value/weight)%0A%09    %09%09%7D%0A%09    %09%7D%0A    %09%7D%0A    %09return null;%0A    %7D%0A
 %7D%0A%0A

Change command to have a parse method, which is incomplete for picking and dropping items