package seedu.ezdo.logic.commands;

import seedu.ezdo.commons.core.Messages;
import seedu.ezdo.commons.core.UnmodifiableObservableList;
import seedu.ezdo.logic.commands.exceptions.CommandException;
import seedu.ezdo.model.todo.ReadOnlyTask;
import seedu.ezdo.model.todo.UniqueTaskList.TaskNotFoundException;

/**
 * Deletes a task identified using its last displayed index from ezDo.
 */
public class KillCommand extends Command {

    public static final String COMMAND_WORD = "kill";
    public static final String SHORT_COMMAND_WORD = "k";

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

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

    public final int targetIndex;

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


    @Override
    public CommandResult execute() throws CommandException {

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

        if (lastShownList.size() < targetIndex) {
            throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
        }

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

        try {
            model.killTask(taskToKill);
        } catch (TaskNotFoundException tnfe) {
            assert false : "The target task cannot be missing";
        }

        return new CommandResult(String.format(MESSAGE_KILL_TASK_SUCCESS, taskToKill));
    }

}

@@ -29,16 +29,45 @@
 mands;%0A%0A
+import java.util.ArrayList;%0A%0A
 import s
@@ -263,16 +263,51 @@
 lyTask;%0A
+import seedu.ezdo.model.todo.Task;%0A
 import s
@@ -974,31 +974,102 @@
 c final 
-int targetIndex
+ArrayList%3CInteger%3E targetIndexes;%0A    public final ArrayList%3CReadOnlyTask%3E tasksToKill
 ;%0A%0A    p
@@ -1086,19 +1086,34 @@
 Command(
-int
+ArrayList%3CInteger%3E
  targetI
@@ -1108,32 +1108,34 @@
 ger%3E targetIndex
+es
 ) %7B%0A        this
@@ -1146,16 +1146,18 @@
 getIndex
+es
  = targe
@@ -1162,16 +1162,71 @@
 getIndex
+es;%0A        tasksToKill = new ArrayList%3CReadOnlyTask%3E()
 ;%0A    %7D%0A
@@ -1414,42 +1414,36 @@
 if (
-lastShownList.size() %3C targetIndex
+!isIndexValid(lastShownList)
 ) %7B%0A
@@ -1552,69 +1552,235 @@
     
-ReadOnlyTask taskToKill = lastShownList.get(targetIndex - 1);
+for (int i = 0; i %3C targetIndexes.size(); i++) %7B%0A            ReadOnlyTask taskToKill = lastShownList.get(targetIndexes.get(i) - 1);%0A            tasksToKill.add(taskToKill);%0A            System.out.println(tasksToKill);%0A        %7D
 %0A%0A  
@@ -1817,21 +1817,23 @@
 killTask
+s
 (task
+s
 ToKill);
@@ -2029,24 +2029,25 @@
 UCCESS, task
+s
 ToKill));%0A  
@@ -2051,10 +2051,209 @@
 %0A    %7D%0A%0A
+    private boolean isIndexValid(UnmodifiableObservableList%3CReadOnlyTask%3E lastShownList) %7B%0A        return targetIndexes.stream().allMatch(index -%3E index %3C= lastShownList.size() && index != 0);%0A    %7D%0A
 %7D%0A

Update KillCommand's execution