Skip to content

Commit

Permalink
Duke Level-9: Making Find more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
nicljr committed Feb 11, 2023
1 parent be2ea3e commit 00bdbb8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ public class FindCommand extends Command {
public FindCommand(String textCmd) {
super(textCmd);
}


/**
* Produces a String for the GUI to read from.
* The String is the list of Tasks that contain that specific given keyword
*
* @param ui User Interface of Duke.
* @param storage storage of Duke.
* @param taskList task list containing all the tasks Duke is tracking.
* @return the String of all the tasks that contains the keyword.
*/
@Override
public String execute(Ui ui, Storage storage, TaskList taskList) throws DukeException {
String[] commandSplit = textCmd.split(" ");
Expand All @@ -22,7 +31,8 @@ public String execute(Ui ui, Storage storage, TaskList taskList) throws DukeExce
}

if (commandSplit.length == 1) {
throw new DukeException("The keyword for your Find Command cannot be blank!\n");
throw new DukeException("The keyword for your Find Command cannot be blank!\n"
+ "Please follow this format: find {keyword}");
}

String keyWord = textCmd.substring(5);
Expand Down

0 comments on commit 00bdbb8

Please # to comment.