Skip to content

Commit

Permalink
fix a bug in displaying error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaseTiong committed Oct 20, 2016
1 parent 8716d6e commit f203078
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/seedu/todo/controllers/ListController.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public void process(String input) {
//setting up view

}
setupView(isTask, listAll, isCompleted, listAllStatus, dateOn, dateFrom, dateTo, isDateProvided, isExactCommand, input);
setupView(isTask, listAll, isCompleted, listAllStatus, dateOn, dateFrom, dateTo, isDateProvided,
parsedDates, isExactCommand, input);

}

Expand All @@ -134,7 +135,7 @@ public void process(String input) {
*/
private void setupView(boolean isTask, boolean listAll, boolean isCompleted,
boolean listAllStatus, LocalDateTime dateOn, LocalDateTime dateFrom,
LocalDateTime dateTo, boolean isDateProvided, boolean isExactCommand, String input) {
LocalDateTime dateTo, boolean isDateProvided, String[] parsedDates, boolean isExactCommand, String input) {
TodoListDB db = TodoListDB.getInstance();
List<Task> tasks = null;
List<Event> events = null;
Expand All @@ -153,7 +154,7 @@ private void setupView(boolean isTask, boolean listAll, boolean isCompleted,
}

if (tasks == null && events == null) {
displayErrorMessage(input, listAll, listAllStatus, isCompleted, isTask, dateOn, dateFrom, dateTo);
displayErrorMessage(input, listAll, listAllStatus, isCompleted, isTask, parsedDates);
return ; //display error message
}

Expand All @@ -173,7 +174,7 @@ private void setupView(boolean isTask, boolean listAll, boolean isCompleted,
if (numTasks != 0 || numEvents != 0) {
consoleMessage = String.format(MESSAGE_LISTING_SUCCESS, formatDisplayMessage(numTasks, numEvents));
} else {
consoleMessage = "No items found!";
consoleMessage = MESSAGE_LISTING_FAILURE;
}

Renderer.renderIndex(db, consoleMessage, tasks, events);
Expand All @@ -189,7 +190,7 @@ private void setupView(boolean isTask, boolean listAll, boolean isCompleted,
* the date entered by the user
*/
private void displayErrorMessage(String input, boolean listAll, boolean listAllStatus, boolean isCompleted,
boolean isTask, LocalDateTime dateOn, LocalDateTime dateFrom, LocalDateTime dateTo) {
boolean isTask, String[] parsedDates) {
String consoleDisplayMessage = String.format("You have entered : %s.",input);
String commandLineMessage = COMMAND_SYNTAX;
String commandLineCompleteSuggestMessage = "complete";
Expand All @@ -213,8 +214,8 @@ private void displayErrorMessage(String input, boolean listAll, boolean listAllS
}
}

if (dateOn != null || dateFrom != null || dateTo != null) {
if (dateOn != null) {
if (parsedDates != null) {
if (parsedDates[0] != null) {
commandLineMessage = String.format("%s by <date>", commandLineMessage);
} else {
commandLineMessage = String.format("%s from <date> to <date>", commandLineMessage);
Expand Down

0 comments on commit f203078

Please sign in to comment.