forked from nus-cs2103-AY1920S1/duke
-
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.
Completed Level 9 Find
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Represents the Command for searching Tasks with a specified keyword. | ||
* A sub-class of Command. | ||
*/ | ||
public class FindCommand extends Command { | ||
|
||
/** | ||
* Overridden execute method from Command to search for Task objects whose | ||
* description matches the search term. The method will output all Tasks that | ||
* contain the search term in the description. It will throw an exception if | ||
* the search term is empty. | ||
* @param storage Storage object for saving purposes | ||
* @param tasks Contains the list of tasks | ||
* @param ui Holds Ui printing method and user input field | ||
* @throws DukeException If searchTerm is empty | ||
*/ | ||
@Override | ||
public void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException { | ||
String searchTerm = ui.readDesc().trim(); | ||
if(searchTerm.isEmpty()){ | ||
throw new DukeException("Search term cannot be blank."); | ||
} | ||
tasks.searchTaskList(searchTerm); | ||
} | ||
} |
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