forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from CS2103AUG2016-T17-C1/marktask
Marktask
- Loading branch information
Showing
18 changed files
with
609 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seedu.task.logic.commands; | ||
|
||
import seedu.task.commons.core.Messages; | ||
import seedu.task.commons.core.UnmodifiableObservableList; | ||
import seedu.task.model.task.ReadOnlyTask; | ||
import seedu.task.model.task.UniqueTaskList.DuplicateTaskException; | ||
import seedu.task.model.task.UniqueTaskList.TaskNotFoundException; | ||
|
||
//@@author A0127720M | ||
|
||
public class MarkCommand extends Command{ | ||
|
||
public static final String COMMAND_WORD = "mark"; | ||
public static final String MESSAGE_SUCCESS = "Marks a given task: $1%s "; | ||
public static final Object MESSAGE_USAGE = " "; | ||
private int targetIndex; | ||
|
||
|
||
//Construct a new mark command | ||
public MarkCommand(int targetIndex) { | ||
this.targetIndex = targetIndex; | ||
} | ||
|
||
@Override | ||
public CommandResult execute() { | ||
//Check index | ||
UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList(); | ||
|
||
if (lastShownList.size() < targetIndex) { | ||
indicateAttemptToExecuteIncorrectCommand(); | ||
return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); | ||
} | ||
|
||
//mark a task | ||
ReadOnlyTask taskToMark = lastShownList.get(targetIndex - 1); | ||
try { | ||
model.markTask(taskToMark); | ||
} catch (TaskNotFoundException pnfe) { | ||
assert false : "The target task cannot be missing"; | ||
} catch (DuplicateTaskException e) { | ||
assert false: "Redundant tasks"; | ||
} | ||
|
||
return new CommandResult(String.format(MESSAGE_SUCCESS, taskToMark)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.