forked from nus-cs2113-AY2324S2/ip
-
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 #1 from Kobot7/branch-Level-9
Add find task feature
Showing
5 changed files
with
63 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kobot.command; | ||
|
||
import kobot.task.TaskList; | ||
import kobot.task.Task; | ||
import kobot.ui.Ui; | ||
|
||
public class FindCommand extends Command { | ||
private String keyword; | ||
|
||
public FindCommand(TaskList tasklist, String keyword) { | ||
super(tasklist); | ||
parseArguments(keyword); | ||
} | ||
|
||
public void parseArguments(String keyword) { | ||
try { | ||
this.keyword = keyword.trim(); | ||
} catch (NullPointerException exception) { | ||
Ui.printMissingArgumentErrorMessage(); | ||
Ui.printFindCommandUsage(); | ||
return; | ||
} | ||
|
||
if (this.keyword.isEmpty()) { | ||
Ui.printEmptyArgumentErrorMessage(); | ||
Ui.printFindCommandUsage(); | ||
return; | ||
} | ||
|
||
this.canExecute = true; | ||
} | ||
public void execute() { | ||
if (!canExecute) { | ||
return; | ||
} | ||
|
||
taskList.findTasks(keyword); | ||
} | ||
} |
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