package seedu.address.logic.commands;

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

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.person.Name;
import seedu.address.model.person.Task;
import seedu.address.model.person.UniqueTaskList;
import seedu.address.model.tag.Tag;
import seedu.address.model.tag.UniqueTagList;

/**
 * Adds a task to the ToDoApp.
 */
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 ToDoApp. "
            + "Parameters: NAME [d/DEADLINE] [p/PRIORITY] [t/TAG] [n/NOTES]...\n"
            + "Example: " + COMMAND_WORD
            + " Buy Printer";

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

    private final Task toAdd;
 
    /**
     * Creates an AddCommand using raw values.
     *
     * @throws IllegalValueException if any of the raw values are invalid
     */
    public AddCommand(String name, 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 Name(name),
                new UniqueTagList(tagSet)
        );
    }

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

    }

}
@@ -1195,23 +1195,23 @@
 me, 
-Set%3C
 String
-%3E tag
+... input
 s)%0A 
@@ -1313,89 +1313,979 @@
     
-for (String tagName : tags) %7B%0A            tagSet.add(new Tag(tagName));%0A        %7D
+String deadline;%0A        int priority;%0A        String notes;%0A        boolean tagging = false;%0A        boolean noting = false;%0A        %0A        for (String input : inputs) %7B%0A            if(input.startsWith(%22d/%22))%7B%0A                deadline = input.substring(2);%0A            %7Delse if(input.startsWith(%22p/%22))%7B%0A                priority = Integer.parseInt(input.substring(2));%0A            %7Delse if(input.startsWith(%22t/%22))%7B%0A                noting = false;%0A                tagSet.add(new Tag(input.substring(2)));%0A                tagging = true;%0A            %7Delse if(input.startsWith(%22n/%22))%7B%0A                tagging = false;%0A                notes.concat(input.substring(2) + %22 %22);%0A                noting = true;%0A            %7Delse%7B%0A                if(tagging == true) %7B%0A                    tagSet.add(input);%0A                %7Delse if(noting == true) %7B%0A                    notes.concat(input + %22 %22);%0A                %7D%0A            %7D%0A        %7D%0A        %0A        notes.trim();%0A        
 %0A   

update addcommand