package ruby.keyboardwarrior.commands;

import ruby.keyboardwarrior.data.exception.IllegalValueException;
import ruby.keyboardwarrior.data.task.*;
import ruby.keyboardwarrior.data.tag.Tag;
//import ruby.keyboardwarrior.data.tag.UniqueTagList;

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

/**
 * Adds a person to the address book.
 */
public class AddCommand extends Command {

    public static final String COMMAND_WORD = "add";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a person to the address book. "
            + "Contact details can be marked private by prepending 'p' to the prefix.\n\t"
            + "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS  [t/TAG]...\n\t"
            + "Example: " + COMMAND_WORD
            + " John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney";

    public static final String MESSAGE_SUCCESS = "New person added: %1$s";
    public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";

    private final Task toAdd;

    /**
     * Convenience constructor using raw values.
     *
     * @throws IllegalValueException if any of the raw values are invalid
     */
    public AddCommand(String name,
                      String phone, boolean isPhonePrivate,
                      String email, boolean isEmailPrivate,
                      String address, boolean isAddressPrivate,
                      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 TaskDetails(name),
                new Phone(phone, isPhonePrivate),
                new Email(email, isEmailPrivate),
                new Address(address, isAddressPrivate)/*,
                new UniqueTagList(tagSet)*/
        );
    }

    public AddCommand(Task toAdd) {
        this.toAdd = toAdd;
    }

    public ReadOnlyTask getPerson() {
        return toAdd;
    }

    @Override
    public CommandResult execute() throws Exception{
        try {
            tasksList.addTask(toAdd);
            return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
        } catch (UniqueTasksList.DuplicateTaskException dpe) {
            return new CommandResult(MESSAGE_DUPLICATE_PERSON);
        }
    }
    
    @Override
    public boolean isMutating() {
    	return true;
    }
}

@@ -511,359 +511,518 @@
 s a 
-person to the address book. %22%0A            + %22Contact details can be marked private by prepending 'p' to the prefix.%5Cn%5Ct%22%0A            + %22Parameters: NAME %5Bp%5Dp/PHONE %5Bp%5De/EMAIL %5Bp%5Da/ADDRESS  %5Bt/TAG%5D...%5Cn%5Ct%22%0A            + %22Example: %22 + COMMAND_WORD%0A            + %22 John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
+task into the Keyboard Warrior.%5Cn%22%0A            + %22Parameters for Floating Task: TASK %5Cn%5Ct%22%0A            + %22Example: %22 + COMMAND_WORD%0A            + %22add do the dishes%5Cn%22%0A%09%09    + %22Parameters for Deadlines: TASK by %5BDATE%5D %5BTIME%5D %5Cn%5Ct%22%0A%09%09    + %22Example: %22 + COMMAND_WORD%0A%09%09    + %22add do CS2103 Tutorial by Wednesday%5Cn%22%0A            + %22Parameters for Specific Task: DATE TIME %5Bto TIME%5D TASK %5B@VENUE%5D %5Cn%5Ct%22%0A            + %22Example: %22 + COMMAND_WORD%0A            + %22add 010616 1800 to 2000 Go to the Mall @Clementi Mall%5Cn
 %22;%0A%0A
@@ -1075,22 +1075,20 @@
  = %22New 
-person
+task
  added: 
@@ -1187,28 +1187,35 @@
  in the 
-address book
+Keyboard Warrior.%5Cn
 %22;%0A%0A    

Update the Add Command function