package seedu.manager.logic.commands;

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

import seedu.manager.commons.core.Messages;
import seedu.manager.commons.core.UnmodifiableObservableList;
import seedu.manager.commons.exceptions.IllegalValueException;
import seedu.manager.model.activity.Activity;
import seedu.manager.model.activity.ActivityList.ActivityNotFoundException;
import seedu.manager.model.tag.Tag;
import seedu.manager.model.tag.UniqueTagList;

/**
 * Updates an activity in Remindaroo
 */

public class UpdateCommand extends Command {
	public static final String COMMAND_WORD = "update";

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

    public static final String MESSAGE_UPDATE_ACTIVITY_SUCCESS = "Updated Activity: %1$s";
	public final int targetIndex;
	public final String newName;

	public UpdateCommand(int targetIndex, String newName) {
		this.targetIndex = targetIndex;
		this.newName = newName;
	}
	
	@Override
	public CommandResult execute() {
		UnmodifiableObservableList<Activity> lastShownList = model.getFilteredActivityList();

        if (lastShownList.size() < targetIndex) {
            indicateAttemptToExecuteIncorrectCommand();
            return new CommandResult(Messages.MESSAGE_INVALID_ACTIVITY_DISPLAYED_INDEX);
        }

        Activity activityToUpdate = lastShownList.get(targetIndex - 1);
        try {
            model.updateActivity(activityToUpdate, newName);
        } catch (ActivityNotFoundException anfe) {
            assert false : "The target activity cannot be found";
        }

        return new CommandResult(String.format(MESSAGE_UPDATE_ACTIVITY_SUCCESS, activityToUpdate.getName()));
    }
}


@@ -36,57 +36,8 @@
 s;%0A%0A
-import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 impo
@@ -1002,16 +1002,196 @@
 ewName;%0A
+%09public String newDateTime;%0A%09public String newEndDateTime;%0A%0A%09/**%0A%09 * Constructor for floating tasks%0A%09 * %0A%09 * @throws IllegalValueException if any of the raw values are invalid%0A%09 */
 %0A%09public
@@ -1237,16 +1237,45 @@
 newName)
+ throws IllegalValueException
  %7B%0A%09%09thi
@@ -1334,16 +1334,650 @@
 e;%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Constructor for deadline tasks%0A%09 * %0A%09 * @throws IllegalValueException if any of the raw values are invalid%0A%09 */%0A%09public UpdateCommand(int targetIndex, String newName, String dateTime) throws IllegalValueException %7B%0A%09%09this(targetIndex, newName);%0A%09%09this.newDateTime = dateTime;%0A%09%7D%0A%09%0A%09/**%0A%09 * Constructor for event tasks%0A%09 * %0A%09 * @throws IllegalValueException if any of the raw values are invalid%0A%09 */%0A%09public UpdateCommand(int targetIndex, String newName, String dateTime, String endDateTime) throws IllegalValueException %7B%0A%09%09this(targetIndex, newName);%0A%09%09this.newDateTime = dateTime;%0A%09%09this.newEndDateTime = endDateTime;%0A%09%7D%0A%09%0A
 %09@Overri
@@ -2452,16 +2452,45 @@
  newName
+, newDateTime, newEndDateTime
 );%0A     

Add constructors for different type of activities in UpdateCommand class