package seedu.taskell.logic.commands;

import seedu.taskell.commons.core.EventsCenter;
import seedu.taskell.commons.core.Messages;
import seedu.taskell.commons.events.ui.IncorrectCommandAttemptedEvent;
import seedu.taskell.commons.events.ui.JumpToListRequestEvent;
import seedu.taskell.model.Model;

/**
 * Represents a command with hidden internal logic and the ability to be executed.
 */
public abstract class Command {
    protected Model model;

    /**
     * Constructs a feedback message to summarise an operation that displayed a listing of tasks.
     *
     * @param displaySize used to generate summary
     * @return summary message for tasks displayed
     */
    public static String getMessageForTaskListShownSummary(int displaySize) {
        return String.format(Messages.MESSAGE_TASKS_LISTED_OVERVIEW, displaySize);
    }

    /**
     * Executes the command and returns the result message.
     *
     * @return feedback message of the operation result for display
     */
    public abstract CommandResult execute();

    /**
     * Provides any needed dependencies to the command.
     * Commands making use of any of these should override this method to gain
     * access to the dependencies.
     */
    public void setData(Model model) {
        this.model = model;
    }

    /**
     * Raises an event to indicate an attempt to execute an incorrect command
     */
    protected void indicateAttemptToExecuteIncorrectCommand() {
        EventsCenter.getInstance().post(new IncorrectCommandAttemptedEvent(this));
    }
    
    //@@author A0139257X-reused
    /**
     * Raises an event to jump to the given index
     */
    protected void jumpToIndex(int index) {
        EventsCenter.getInstance().post(new JumpToListRequestEvent(index));
    }
    //@@author
}

@@ -254,24 +254,103 @@
 questEvent;%0A
+import seedu.taskell.model.History;%0Aimport seedu.taskell.model.HistoryManager;%0A
 import seedu
@@ -521,16 +521,54 @@
 l model;
+%0A    protected static History history;
 %0A%0A    /*
@@ -1403,24 +1403,164 @@
 model;%0A    %7D
+%0A    %0A    /**%0A     * initialize History%0A     */%0A    public static void initHistory() %7B%0A        history = HistoryManager.getInstance();%0A    %7D
 %0A%0A    /**%0A  

add History as static variable accessible to all children classes