package udo.logic;

public class Logic {
    private static final String ERROR_FORMAT = "Error: %s";
    private static final String ERROR_INVALID_CMD_NAME =
            "Invalid command name";
    
    private InputParser parser;
    
    private static String status;
    
    public Logic() {
        parser = new InputParser();
        /* TODO:
         * Initialize Storage
         * Initialize and start up passive thread for reminder
         */
    }
    
    /******************************
     * Code for the active logics *
     ******************************/
    
    /**
     * Execute the command given in the command string 
     * @param command the command string
     */
    public void executeCommand(String command) {
        Command parsedCommand = parser.parseCommand(command);
        
        if (isCommandValid(parsedCommand)) {
        } else {
           // TODO: Inform GUI of error status 
        }
    }

    /**
     * Check the semantics of a parsed command
     * @param parsedCommand
     * @return the command's correctness
     */
    private boolean isCommandValid(Command parsedCommand) {
        if (parsedCommand == null || parsedCommand.commandName == null ||
            parsedCommand.commandName.trim().equalsIgnoreCase("")) {
            status = formatErrorStr(ERROR_INVALID_CMD_NAME);
            return false;
        }
        return true;
    }

    private String formatErrorStr(String errorInvalidCmdName) {
        return String.format(ERROR_FORMAT, errorInvalidCmdName);
    }
}

@@ -13,16 +13,41 @@
 logic;%0A%0A
+import udo.util.Config;%0A%0A
 public c
@@ -212,16 +212,107 @@
  name%22;%0A
+    private static final String ERROR_UNSUPPORTED_CMD =%0A            %22Unsupported command%22;%0A
     %0A   
@@ -1492,18 +1492,1183 @@
     
-return tru
+%0A        String cmdName = parsedCommand.commandName;%0A        if (cmdName.equalsIgnoreCase(Config.CMD_STR_ADD)) %7B%0A            return isAddCmdValid(parsedCommand); %0A        %7D else if (cmdName.equalsIgnoreCase(Config.CMD_STR_DELETE)) %7B%0A            return isDeleteCmdValid(parsedCommand);%0A        %7D else if (cmdName.equalsIgnoreCase(Config.CMD_STR_MODIFY)) %7B%0A            return isModifyCmdValid(parsedCommand);%0A        %7D else if (cmdName.equalsIgnoreCase(Config.CMD_STR_DISPLAY)) %7B%0A            return isDisplayCmdValid(parsedCommand);%0A        %7D else %7B%0A            status = formatErrorStr(ERROR_UNSUPPORTED_CMD);%0A            return false;%0A        %7D%0A    %7D%0A%0A    private boolean isDisplayCmdValid(Command parsedCommand) %7B%0A        // TODO Auto-generated method stub%0A        return false;%0A    %7D%0A%0A    private boolean isModifyCmdValid(Command parsedCommand) %7B%0A        // TODO Auto-generated method stub%0A        return false;%0A    %7D%0A%0A    private boolean isDeleteCmdValid(Command parsedCommand) %7B%0A        // TODO Auto-generated method stub%0A        return false;%0A    %7D%0A%0A    private boolean isAddCmdValid(Command parsedCommand) %7B%0A        // TODO Auto-generated method stub%0A        return fals
 e;%0A 
@@ -2808,10 +2808,9 @@
 ;%0A    %7D%0A
+
 %7D
-%0A

Add more skeleton code and error checking to logic