package seedu.task.logic.commands;

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

//@@author A0127720M

public class MarkCommand extends Command{

    public static final String COMMAND_WORD = "mark";
    public static final String SHORTCUT = "m";
    public static final String MESSAGE_SUCCESS = "Marks a given task: %1$s ";
	public static final Object MESSAGE_USAGE = " ";
	private int targetIndex;
    
    
	//Construct a new mark command
	public MarkCommand(int targetIndex) {
		this.targetIndex = targetIndex;
	}
	
	@Override
	public CommandResult execute() {
		//Check index
		UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

        if (lastShownList.size() < targetIndex) {
            indicateAttemptToExecuteIncorrectCommand();
            return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
        }
        
        //mark a task 
        ReadOnlyTask taskToMark = lastShownList.get(targetIndex - 1);
        try {
            model.markTask(taskToMark);
        } catch (TaskNotFoundException pnfe) {
            assert false : "The target task cannot be missing";
        } catch (DuplicateTaskException e) {
			assert false: "Redundant tasks";
		}
        
        return new CommandResult(String.format(MESSAGE_SUCCESS, taskToMark));
	}
}

@@ -370,16 +370,17 @@
  Command
+ 
 %7B%0A%0A    p
@@ -518,48 +518,244 @@
 AGE_
-SUCCESS = %22Marks a given task: %251$s %22;%0A%09
+USAGE = COMMAND_WORD%0A            + %22: Marks the selected task as completed and display the task in the 'completed task panel'.%5Cn%22%0A            + %22Parameters: INDEX (must be a positive integer)%5Cn%22 + %22Example: %22 + COMMAND_WORD + %22 1%22;%0A    
 publ
@@ -774,14 +774,14 @@
 nal 
-Object
+String
  MES
@@ -789,22 +789,52 @@
 AGE_
-USAGE = %22 %22;%0A%09
+SUCCESS = %22Marks a given task: %251$s %22;%0A%0A    
 priv
@@ -858,21 +858,16 @@
 ex;%0A
-    
 %0A    
-%0A%09
 //
+ 
 Cons
@@ -891,17 +891,20 @@
 command%0A
-%09
+    
 public M
@@ -933,18 +933,24 @@
 ndex) %7B%0A
-%09%09
+        
 this.tar
@@ -977,14 +977,19 @@
 ex;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 @Ove
@@ -994,17 +994,20 @@
 verride%0A
-%09
+    
 public C
@@ -1035,12 +1035,19 @@
 ) %7B%0A
-%09%09
+        
 //
+ 
 Chec
@@ -1054,18 +1054,24 @@
 k index%0A
-%09%09
+        
 Unmodifi
@@ -1350,24 +1350,16 @@
       %7D%0A
-        
 %0A       
@@ -1361,16 +1361,17 @@
       //
+ 
 mark a t
@@ -1373,17 +1373,16 @@
 k a task
- 
 %0A       
@@ -1658,11 +1658,20 @@
 ) %7B%0A
-%09%09%09
+            
 asse
@@ -1678,16 +1678,17 @@
 rt false
+ 
 : %22Redun
@@ -1704,20 +1704,16 @@
 s%22;%0A
-%09%09%7D%0A
         
 %0A   
@@ -1708,16 +1708,18 @@
         
+%7D%0A
 %0A       
@@ -1793,9 +1793,12 @@
 ));%0A
-%09
+    
 %7D%0A%7D%0A

Solve further merge conflicts