File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 17
17
import static duke .ui .MessageConstants .MESSAGE_ERROR_EMPTY_DESCRIPTION ;
18
18
import static duke .ui .MessageConstants .MESSAGE_ERROR_FROM_TIME_MISSING ;
19
19
import static duke .ui .MessageConstants .MESSAGE_ERROR_TO_TIME_MISSING ;
20
+ import static duke .ui .MessageConstants .MESSAGE_ERROR_TO_BEFORE_FROM ;
20
21
import static duke .ui .MessageConstants .MESSAGE_ERROR_DEADLINE_BY ;
21
22
import static duke .ui .MessageConstants .MESSAGE_ERROR_COMMAND ;
22
23
import static duke .ui .MessageConstants .MESSAGE_ERROR_FIND_MISSING ;
23
24
25
+
24
26
import static duke .parser .TaskConstants .DEADLINE ;
25
27
import static duke .parser .TaskConstants .EVENT ;
26
28
import static duke .parser .TaskConstants .TODO ;
@@ -136,6 +138,10 @@ public static AddEventCommand parseEventCommand(String commandRawInput) throws D
136
138
throw new DukeException (MESSAGE_ERROR_TO_TIME_MISSING );
137
139
}
138
140
141
+ if (toPos < fromPos ) {
142
+ throw new DukeException (MESSAGE_ERROR_TO_BEFORE_FROM );
143
+ }
144
+
139
145
//get the task name
140
146
String description = commandRawInput .substring (0 ,fromPos ).trim ();
141
147
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public class MessageConstants {
27
27
public static final String MESSAGE_ERROR_EMPTY_DESCRIPTION = "☹ OOPS!!! The description of a task cannot be empty." ;
28
28
public static final String MESSAGE_ERROR_FROM_TIME_MISSING = "☹ OOPS!!! The /from time of an event cannot be empty." ;
29
29
public static final String MESSAGE_ERROR_TO_TIME_MISSING = "☹ OOPS!!! The /to time of an event cannot be empty." ;
30
+ public static final String MESSAGE_ERROR_TO_BEFORE_FROM = "☹ OOPS!!! The /from time of an event must be typed before the /to time." ;
30
31
public static final String MESSAGE_ERROR_DEADLINE_BY = "☹ OOPS!!! The /by time of a deadline cannot be empty." ;
31
32
public static final String MESSAGE_ERROR_FIND_MISSING = "☹ OOPS!!! The word you are searching for cannot be empty." ;
32
33
public static final String MESSAGE_ERROR_FILE_CREATION = "☹ OOPS!!! Error creating file." ;
You can’t perform that action at this time.
0 commit comments