package seedu.taskboss.logic.commands;

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

/**
 * Deletes a task identified using it's last displayed index from TaskBoss.
 */
public class DeleteCommand extends Command {

    public static final String COMMAND_WORD = "delete";
    public static final String COMMAND_WORD_SHORT = "d";

    public static final String MESSAGE_USAGE = COMMAND_WORD + "/" + COMMAND_WORD_SHORT
            + ": 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" + " || " + COMMAND_WORD_SHORT + " 1";

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

    public final int targetIndex;

    public DeleteCommand(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 taskToDelete = lastShownList.get(targetIndex - 1);

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

        return new CommandResult(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
    }

}

@@ -33,16 +33,97 @@
 mands;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.Set;%0A%0A
 import s
@@ -1090,19 +1090,34 @@
 c final 
-int
+ArrayList%3CInteger%3E
  targetI
@@ -1123,16 +1123,142 @@
 Index;%0A%0A
+    public final ArrayList%3CReadOnlyTask%3E tasksToDelete;%0A%0A    /**%0A    * Set will automatically remove duplicate indexes%0A    */%0A
     publ
@@ -1274,19 +1274,28 @@
 Command(
-int
+Set%3CInteger%3E
  targetI
@@ -1329,16 +1329,39 @@
 Index = 
+new ArrayList%3CInteger%3E(
 targetIn
@@ -1363,18 +1363,177 @@
 getIndex
+)
 ;%0A
+        Collections.sort(this.targetIndex);%0A        Collections.reverse(this.targetIndex);%0A        this.tasksToDelete = new ArrayList%3CReadOnlyTask%3E();       %0A
     %7D%0A%0A%0A
@@ -1699,24 +1699,150 @@
 askList();%0A%0A
+        for (int index: targetIndex) %7B%0A            ReadOnlyTask taskToDelete = lastShownList.get(index - 1);%0A            %0A    
         if (
@@ -1864,23 +1864,17 @@
 ize() %3C 
-targetI
+i
 ndex) %7B%0A
@@ -1885,16 +1885,20 @@
         
+  
+  
 throw ne
@@ -1976,84 +1976,152 @@
     
-%7D%0A%0A        ReadOnlyTask taskToDelete = lastShownList.get(targetIndex - 1);%0A%0A
+    %7D%0A            %0A            tasksToDelete.add(taskToDelete);%0A        %7D%0A        %0A        for (ReadOnlyTask taskToDelete: tasksToDelete) %7B%0A    
     
@@ -2130,16 +2130,20 @@
   try %7B%0A
+    
         
@@ -2186,16 +2186,20 @@
         
+   
+ 
 %7D catch 
@@ -2225,24 +2225,28 @@
 ion pnfe) %7B%0A
+    
             
@@ -2297,16 +2297,30 @@
 ssing%22;%0A
+            %7D%0A
         
@@ -2321,16 +2321,24 @@
       %7D%0A
+        
 %0A       

Update DeleteCommand.java