package seedu.address.logic.commands;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.UnmodifiableObservableList;
import seedu.address.model.task.ReadOnlyTask;
import seedu.address.model.task.UniqueTaskList.TaskNotFoundException;

/**
 * Deletes a person identified using it's last displayed index from the address book.
 */
public class DeleteCommand extends Command {

    public static final String COMMAND_WORD = "delete";

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

    public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Task: %1$s";

    public final int targetIndex;

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


    @Override
    public CommandResult execute() {

        UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

        if (lastShownList.size() < targetIndex) {
            indicateAttemptToExecuteIncorrectCommand();
            return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
        }

        ReadOnlyTask personToDelete = lastShownList.get(targetIndex - 1);

        try {
            model.deleteTask(personToDelete);
        } catch (TaskNotFoundException pnfe) {
            assert false : "The target person cannot be missing";
        }

        return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete));
    }

}

@@ -541,22 +541,21 @@
 tes the 
-person
+ Task
  identif
@@ -595,22 +595,20 @@
 he last 
-person
+Task
  listing
@@ -765,38 +765,36 @@
  MESSAGE_DELETE_
-PERSON
+TASK
 _SUCCESS = %22Dele
@@ -1308,22 +1308,20 @@
 nlyTask 
-person
+Task
 ToDelete
@@ -1403,22 +1403,20 @@
 eteTask(
-person
+Task
 ToDelete
@@ -1504,22 +1504,20 @@
  target 
-person
+task
  cannot 
@@ -1606,14 +1606,12 @@
 ETE_
-PERSON
+TASK
 _SUC
@@ -1616,22 +1616,20 @@
 UCCESS, 
-person
+Task
 ToDelete

update delete command to delete task at the specified index