forked from nus-cs2103-AY2324S1/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.
Add reminders command to show nearest deadline or event.
- Loading branch information
Showing
3 changed files
with
52 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
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,29 @@ | ||
package duke.command; | ||
|
||
import duke.TaskList; | ||
import duke.Ui; | ||
import duke.exception.DukeException; | ||
|
||
/** | ||
* FindCommand to search for a task in the taskList. | ||
*/ | ||
public class ReminderCommand implements Command { | ||
|
||
/** | ||
* Find the nearest dated task. | ||
* @param tasks The task list that may be modified by the command. | ||
* @param ui The user interface for analyzing chat history. | ||
* @return false as it should not exit. | ||
* @throws DukeException when error occurs. | ||
*/ | ||
@Override | ||
public boolean execute(TaskList tasks, Ui ui) throws DukeException { | ||
String output = tasks.findNearest(); | ||
if (output.trim().length() == 0) { | ||
ui.respond("You don't have any events or deadlines."); | ||
} else { | ||
ui.respond("Reminder: your upcoming task:" + "\n" + tasks.findNearest()); | ||
} | ||
return false; | ||
} | ||
} |