//@@author A0138474X
package seedu.address.logic.commands;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.TaskManager;

/**
 * Clears Dueue.
 */
public class ClearCommand extends AbleUndoCommand {

    public static final String COMMAND_WORD = "clear";
    public static final String COMMAND_CLEAR = "clear command";
    public static final String MESSAGE_SUCCESS = "Dueue has been cleared!";
    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Clear all tasks in Dueue \n"
            + "Parameters: Nil\n"
            + "Example: " + COMMAND_WORD;

    private TaskManager tasks;

    @Override
    public CommandResult execute() {
        assert model != null;
        tasks = TaskManager.getStub();
        tasks.resetData(model.getTaskManager());
        model.resetData(TaskManager.getStub());
        return new CommandResult(CommandFormatter.undoFormatter(MESSAGE_SUCCESS, COMMAND_CLEAR));
    }

    @Override
    public boolean isUndoable() {
        return true;
    }

    @Override
    public CommandResult executeUndo(String message) throws CommandException {
        assert model != null;
        TaskManager tasks = TaskManager.getStub();
        tasks.resetData(model.getTaskManager());
        model.resetData(this.tasks);
        this.tasks = tasks;
        return new CommandResult(CommandFormatter.undoMessageFormatter(message, COMMAND_CLEAR));
    }

    @Override
    public Command getUndoCommand() throws IllegalValueException {
        return this;
    }

    @Override
    public String getUndoCommandWord() {
        return COMMAND_WORD + COMMAND_SUFFIX;
    }

}

@@ -695,16 +695,40 @@
 er tasks
+ = TaskManager.getStub()
 ;%0A%0A    @
@@ -769,24 +769,123 @@
 execute() %7B%0A
+        return execute(MESSAGE_SUCCESS);%0A    %7D%0A%0A    public CommandResult execute(String message) %7B%0A
         asse
@@ -906,24 +906,36 @@
 ll;%0A        
+TaskManager 
 tasks = Task
@@ -1030,30 +1030,47 @@
 ata(
-TaskManager.getStub())
+this.tasks);%0A        this.tasks = tasks
 ;%0A  
@@ -1121,16 +1121,23 @@
 ter.undo
+Message
 Formatte
@@ -1138,31 +1138,23 @@
 rmatter(
-MESSAGE_SUCCESS
+message
 , COMMAN
@@ -1352,289 +1352,30 @@
     
-assert model != null;%0A        TaskManager tasks = TaskManager.getStub();%0A        tasks.resetData(model.getTaskManager());%0A        model.resetData(this.tasks);%0A        this.tasks = tasks;%0A        return new CommandResult(CommandFormatter.undoMessageFormatter(message, COMMAND_CLEAR)
+return execute(message
 );%0A 

apply SLAP on clear Command