package seedu.tasklist.logic.commands;

import seedu.tasklist.logic.commands.exceptions.CommandException;

/**
 * Marks a task as done using its last displayed index from FlexiTask
 * @author A0143355J
 */
public class DoneCommand extends Command {

    public static final String COMMAND_WORD = "done";

    public static final String MESSAGE_USAGE = COMMAND_WORD
            + ": Marks the task identified by the index number used in the last task listing as done.\n"
            + "Parameters: INDEX (must be a positive integer)\n"
            + "Example: " + COMMAND_WORD + " 1";

    public static final String MESSAGE_DONE_TASK_SUCCESS = "Done Task: %1$s";

    public final int targetIndex;

    public DoneCommand(int targetIndex) {
        this.targetIndex = targetIndex;
    }

    @Override
    public CommandResult execute() throws CommandException {
        // TODO Auto-generated method stub
        return null;
    }

}

@@ -44,65 +44,269 @@
 ort 
-seedu.tasklist.logic.commands.exceptions.CommandException
+java.util.List;%0A%0Aimport seedu.tasklist.commons.core.Messages;%0Aimport seedu.tasklist.logic.commands.exceptions.CommandException;%0Aimport seedu.tasklist.model.task.ReadOnlyTask;%0Aimport seedu.tasklist.model.task.Task;%0Aimport seedu.tasklist.model.task.UniqueTaskList
 ;%0A%0A/
@@ -1072,42 +1072,546 @@
     
-// TODO Auto-generated method stub
+List%3CReadOnlyTask%3E lastShownList = model.getFilteredTaskList();%0A%0A        if (lastShownList.size() %3C targetIndex) %7B%0A            throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);%0A        %7D%0A%0A        ReadOnlyTask taskToDone = lastShownList.get(targetIndex - 1);%0A%0A        Task doneTask;%0A%0A        doneTask = createDoneTask(taskToDone);%0A%0A        model.updateTask(targetIndex, doneTask);%0A%0A        model.updateFilteredListToShowAll();%0A        return new CommandResult(String.format(MESSAGE_DONE_TASK_SUCCESS, taskToDone));
 %0A   

update execute in DoneCommand