forked from nus-cs2103-AY2425S1/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.
- Loading branch information
1 parent
414e01c
commit d67dc23
Showing
9 changed files
with
112 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
T | 0 | shoot | ||
D | 0 | eatshiet | 2002-11-11 2020 | ||
T | 1 | 777 | ||
T | 0 | shoot | fun | ||
D | 0 | eatshiet | 2002-11-11 2020 | 2002-11-11 2020 | ||
T | 1 | 777 | lousy | ||
T | 0 | read book | ||
T | 0 | eat fun | ||
T | 0 | ryan eat dog |
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 |
---|---|---|
@@ -1,34 +1,25 @@ | ||
package kobe.command; | ||
|
||
import kobe.task.Task; | ||
import kobe.task.TaskList; | ||
import kobe.util.Storage; | ||
import kobe.util.Ui; | ||
|
||
/** | ||
* Represents a command to find tasks based on a keyword in the task list of the Duke chatbot application. | ||
* Represents a command to find tasks based on a keyword or tag. | ||
*/ | ||
public class FindCommand extends Command { | ||
private final String keyword; | ||
|
||
/** | ||
* Constructs a FindCommand with the specified keyword. | ||
* | ||
* @param keyword The keyword to search for in task descriptions. | ||
*/ | ||
public FindCommand(String keyword) { | ||
this.keyword = keyword; | ||
} | ||
|
||
/** | ||
* Executes the find command, which displays tasks that match the keyword. | ||
* | ||
* @param tasks The TaskList object containing all tasks. | ||
* @param ui The Ui object responsible for user interactions. | ||
* @param storage The Storage object responsible for saving and loading tasks (not used in this command). | ||
*/ | ||
@Override | ||
public void execute(TaskList tasks, Ui ui, Storage storage) { | ||
TaskList matchingTasks = tasks.findTasks(keyword); | ||
TaskList matchingTasks = keyword.startsWith("#") | ||
? tasks.findTasksByTag(keyword.substring(1)) | ||
: tasks.findTasks(keyword); | ||
ui.setResponse("Here are the matching tasks in your list:\n" + matchingTasks.getAllTasksAsString()); | ||
} | ||
} |
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
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.