package seedu.task.logic.commands;

import seedu.task.commons.core.Messages;
import seedu.task.commons.core.UnmodifiableObservableList;
import seedu.task.model.task.Task;
import seedu.task.model.task.ReadOnlyTask;

public class CompleteCommand extends Command {

	public static final String COMMAND_WORD = "complete";

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

	public static final String MESSAGE_COMPLETE_TASK_SUCCESS = "Completed Task: %1$s";

	public final int targetIndex;

	public CompleteCommand(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 orginialTask = lastShownList.get(targetIndex - 1);
		Task completedTask = new Task(orginialTask.getName(), orginialTask.getTags(), orginialTask.getComplete());

		completedTask.setIsCompleted(true);
		model.completeTask(orginialTask, completedTask);

		return new CommandResult(String.format(MESSAGE_COMPLETE_TASK_SUCCESS, orginialTask));
	}
}

@@ -256,17 +256,20 @@
 mand %7B%0A%0A
-%09
+    
 public s
@@ -311,25 +311,28 @@
 complete%22;%0A%0A
-%09
+    
 public stati
@@ -375,25 +375,24 @@
 ND_WORD%0A
-%09
         
 + %22: Mar
@@ -383,16 +383,20 @@
         
+    
 + %22: Mar
@@ -485,17 +485,20 @@
 ted.%5Cn%22%0A
-%09
+    
         
@@ -584,25 +584,28 @@
 RD + %22 1%22;%0A%0A
-%09
+    
 public stati
@@ -676,17 +676,20 @@
 %251$s%22;%0A%0A
-%09
+    
 public f
@@ -711,17 +711,20 @@
 Index;%0A%0A
-%09
+    
 public C
@@ -757,18 +757,24 @@
 ndex) %7B%0A
-%09%09
+        
 this.tar
@@ -797,21 +797,27 @@
 tIndex;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -818,17 +818,20 @@
 verride%0A
-%09
+    
 public C
@@ -855,19 +855,24 @@
 ute() %7B%0A
-%0A%09%09
+        
 Unmodifi
@@ -950,18 +950,24 @@
 ist();%0A%0A
-%09%09
+        
 if (last
@@ -1000,19 +1000,28 @@
 ndex) %7B%0A
-%09%09%09
+            
 indicate
@@ -1060,11 +1060,20 @@
 ();%0A
-%09%09%09
+            
 retu
@@ -1145,15 +1145,27 @@
 X);%0A
-%09%09%7D%0A%0A%09%09
+        %7D%0A%0A        
 Read
@@ -1224,18 +1224,24 @@
 x - 1);%0A
-%09%09
+        
 Task com
@@ -1340,18 +1340,24 @@
 te());%0A%0A
-%09%09
+        
 complete
@@ -1384,18 +1384,24 @@
 (true);%0A
-%09%09
+        
 model.co
@@ -1446,10 +1446,16 @@
 );%0A%0A
-%09%09
+        
 retu
@@ -1540,9 +1540,12 @@
 ));%0A
-%09
+    
 %7D%0A%7D%0A

Fix indentation