Skip to content

Commit

Permalink
Console messages
Browse files Browse the repository at this point in the history
  • Loading branch information
louietyj committed Nov 5, 2016
1 parent 02c42f7 commit bef762c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/seedu/todo/controllers/FindController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class FindController implements Controller {
private static final String COMMAND_SYNTAX = "find <name>";
private static final String COMMAND_WORD = "find";

private static final String MESSAGE_LISTING_SUCCESS = "A total of %s found!";
private static final String MESSAGE_LISTING_SUCCESS = "A total of %s %s and %s %s found!";
private static final String MESSAGE_LISTING_FAILURE = "No tasks or events found!";

private static CommandDefinition commandDefinition =
Expand All @@ -63,6 +63,13 @@ public void process(String input) throws ParseException {
eventPredicates.add(Event.predByName(input));
List<Event> events = Event.where(eventPredicates);

Renderer.renderSelected(TodoListDB.getInstance(), "Done!", tasks, events);
if (tasks.size() == 0 && events.size() == 0) {
Renderer.renderIndex(TodoListDB.getInstance(), MESSAGE_LISTING_FAILURE);
} else {
String consoleMessage = String.format(MESSAGE_LISTING_SUCCESS,
tasks.size(), StringUtil.pluralizer(tasks.size(), "task", "tasks"),
events.size(), StringUtil.pluralizer(events.size(), "event", "events"));
Renderer.renderSelected(TodoListDB.getInstance(), consoleMessage, tasks, events);
}
}
}

0 comments on commit bef762c

Please sign in to comment.