Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assertions in Command classes #4

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public DeleteCommand(String command) {
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
String[] inputTokens = this.command.split(" ");
assert inputTokens[0] == "delete";
int deleteIndex;

try {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/command/DoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public DoneCommand(String command) {
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
String[] inputTokens = this.command.split(" ");
assert inputTokens[0] == "done";

// Mark the task with given index as done
int doneIndex;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ExitCommand(String command) {
*/
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) {
assert command.split(" ")[0] == "bye";
return ui.showGoodBye();
}
}
1 change: 1 addition & 0 deletions src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public FindCommand(String command) {
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) {
String[] inputTokens = this.command.split(" ");
assert inputTokens[0] == "find";
String dateString = (inputTokens.length > 1) ? inputTokens[1] : "";
TaskList filteredTasks = filterByString(tasks, dateString);
return ui.prettyPrintList(filteredTasks);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public ListCommand(String command) {
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) {
String[] inputTokens = this.command.split(" ");
assert inputTokens[0] == "list";
String dateString = (inputTokens.length > 1) ? inputTokens[1] : "";
TaskList filteredTasks = filterTasksByDate(tasks, dateString);
return ui.prettyPrintList(filteredTasks);
Expand Down