package seedu.taskell.logic.commands;

import java.util.HashSet;
import java.util.Set;

import seedu.taskell.commons.exceptions.IllegalValueException;
import seedu.taskell.model.tag.Tag;
import seedu.taskell.model.tag.UniqueTagList;
import seedu.taskell.model.task.*;

/**
 * Adds a task to the task manager.
 */
public class AddCommand extends Command {

    public static final String COMMAND_WORD = "add";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a task to the task manager. "
            + "Parameters: NAME p/TASK_TYPE p/TASK_DATE e/START_TIME e/END_TIME a/TASK_PRIORITY [t/TAG]...\n"
            + "Example: " + COMMAND_WORD
            + " John Doe p/EVENT p/1-1-2015 e/12.30AM e/12.45AM a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney";

    public static final String MESSAGE_SUCCESS = "New task added: %1$s";
    public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in the task manager";

    private final Task toAdd;

    /**
     * Convenience constructor using raw values.
     *
     * @throws IllegalValueException if any of the raw values are invalid
     */

    public AddCommand(String description, String taskType, String taskDate, String startTime, String endTime, String taskPriority, Set<String> tags)
            throws IllegalValueException {
        final Set<Tag> tagSet = new HashSet<>();
        for (String tagName : tags) {
            tagSet.add(new Tag(tagName));
        }
        this.toAdd = new Task(
                new Description(description),
                new String(taskType),
                new TaskDate(taskDate),
                new TaskTime(startTime),
                new TaskTime(endTime),
                new TaskPriority(taskPriority),
                new UniqueTagList(tagSet)
        );
    }

    @Override
    public CommandResult execute() {
        assert model != null;
        try {
            model.addTask(toAdd);
            return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
        } catch (UniqueTaskList.DuplicateTaskException e) {
            return new CommandResult(MESSAGE_DUPLICATE_TASK);
        }

    }

}

@@ -1468,16 +1468,91 @@
         
+%0A        switch (taskType) %7B%0A        case Task.FLOATING_TASK: %0A            
 this.toA
@@ -1556,24 +1556,32 @@
 toAdd = new 
+Floating
 Task(%0A      
@@ -1586,24 +1586,28 @@
             
+ 
+   
 new Descript
@@ -1623,16 +1623,17 @@
 iption),
+ 
 %0A       
@@ -1645,30 +1645,932 @@
     
-new String(taskType),%0A
+    Task.FLOATING_TASK, %0A                    new TaskDate(TaskDate.DEFAULT_DATE), %0A                    new TaskTime(TaskTime.DEFAULT_START_TIME), %0A                    new TaskTime(TaskTime.DEFAULT_END_TIME), %0A                    new TaskPriority(taskPriority),%0A                    new UniqueTagList(tagSet));%0A            break;%0A        case Task.DEADLINE_TASK:%0A            this.toAdd = new DeadlineTask(%0A                    new Description(description),%0A                    Task.DEADLINE_TASK,%0A                    new TaskDate(taskDate),%0A                    new TaskTime(TaskTime.DEFAULT_START_TIME),%0A                    new TaskTime(endTime),%0A                    new TaskPriority(taskPriority),%0A                    new UniqueTagList(tagSet));%0A            break;%0A        case Task.EVENT_TASK:%0A            this.toAdd = new EventTask(%0A                    new Description(description),%0A                    Task.EVENT_TASK,%0A    
     
@@ -2597,32 +2597,36 @@
 Date(taskDate),%0A
+    
                 
@@ -2658,32 +2658,36 @@
                 
+   
+ 
 new TaskTime(end
@@ -2685,32 +2685,36 @@
 kTime(endTime),%0A
+    
                 
@@ -2753,32 +2753,36 @@
                 
+   
+ 
 new UniqueTagLis
@@ -2790,16 +2790,18 @@
 (tagSet)
+);
 %0A       
@@ -2801,18 +2801,79 @@
         
-);
+    break;%0A        default:%0A            toAdd = null;%0A        %7D
 %0A    %7D%0A%0A

Support Floating, Deadline, Event task constructors