Skip to content

Commit

Permalink
Merge pull request #193 from shawnlsj97/master
Browse files Browse the repository at this point in the history
Update calendar command error message
  • Loading branch information
shawnlsj97 committed Nov 5, 2019
2 parents ebc1a01 + 1f41adb commit 4426ce8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public class CalendarCommand extends Command {

public static final String COMMAND_WORD = "calendar";

public static final String MESSAGE_USAGE = "calendar" + ": Jumps to a specified date."
+ " 1) Specify month and year to view calendar for that month.\nParameters: MMYYYY\n"
+ "Example: calendar 062019\n2) Specify day, month and year to view details for that"
+ " date.\nParameters: DDMMYYYY\nExample: calendar 09062019";
public static final String MESSAGE_USAGE = "calendar" + ": Navigates the calendar feature. "
+ "The calendar command has 2 possible variations.\n"
+ "1) Specify month and year to view calendar for particular month.\nParameters: "
+ "MMYYYY\nExample: calendar 062019\n2) Specify day, month and year to view details for "
+ "particular date.\nParameters: DDMMYYYY\nExample: calendar 09062019";

public static final String MESSAGE_SUCCESS_1 = "Viewing details for: ";
public static final String MESSAGE_SUCCESS_2 = "Viewing calendar for: ";
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ public static AthletickDate parseDate(String date) throws ParseException {
if (trimmedDate.length() == 6 || trimmedDate.length() == 8) {
if (trimmedDate.length() == 8) {
return parseDateTypeOne(trimmedDate);
} else if (date.length() == 6) {
} else {
return parseDateTypeTwo(trimmedDate);
}
} else {
throw new ParseException(String.format(AthletickDate.MESSAGE_CONSTRAINTS,
AthletickDate.DATE_FORMAT_GENERAL));
}
// should not reach here
return null;
}

/**
Expand All @@ -121,7 +119,8 @@ public static AthletickDate parseDateTypeOne(String date) throws ParseException
return new AthletickDate(day, month, year, type, mth);
} catch (java.text.ParseException e) {
throw new ParseException(AthletickDate.WRONG_DATE_FORMAT + " "
+ String.format(AthletickDate.MESSAGE_CONSTRAINTS, AthletickDate.DATE_FORMAT_TYPE_ONE));
+ String.format(AthletickDate.MESSAGE_CONSTRAINTS, AthletickDate.DATE_FORMAT_TYPE_ONE)
+ "\n" + AthletickDate.MONTH_CONSTRAINTS + "\n" + AthletickDate.YEAR_CONSTRAINTS);
}
}

Expand All @@ -145,7 +144,8 @@ public static AthletickDate parseDateTypeTwo(String date) throws ParseException
return new AthletickDate(day, month, year, type, mth);
} catch (java.text.ParseException e) {
throw new ParseException(AthletickDate.WRONG_DATE_FORMAT + " "
+ String.format(AthletickDate.MESSAGE_CONSTRAINTS, AthletickDate.DATE_FORMAT_TYPE_TWO));
+ String.format(AthletickDate.MESSAGE_CONSTRAINTS, AthletickDate.DATE_FORMAT_TYPE_TWO)
+ "\n" + AthletickDate.MONTH_CONSTRAINTS + "\n" + AthletickDate.YEAR_CONSTRAINTS);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/model/date/AthletickDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class AthletickDate {
public static final String MESSAGE_CONSTRAINTS = "Please specify date in %s format.";
public static final String WRONG_DATE_FORMAT = "Invalid date specified.";
public static final String ERROR_MESSAGE = WRONG_DATE_FORMAT + " " + MESSAGE_CONSTRAINTS;
public static final String MONTH_CONSTRAINTS = "MM has to be from 01 to 12.";
public static final String YEAR_CONSTRAINTS = "YYYY has to be from 0001 to 9999.";

private int day;
private int month;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void parse_invalidValue_failure() {
// invalid date
assertParseFailure(parser,
VALID_INDEX + EVENT_DESC + INVALID_DATE_DESC + TIMING_DESC, String.format(AthletickDate.ERROR_MESSAGE,
AthletickDate.DATE_FORMAT_TYPE_ONE));
AthletickDate.DATE_FORMAT_TYPE_ONE) + "\n" + AthletickDate.MONTH_CONSTRAINTS
+ "\n" + AthletickDate.YEAR_CONSTRAINTS);

// non-empty preamble
assertParseFailure(parser,
Expand Down

0 comments on commit 4426ce8

Please sign in to comment.