@@ -28,48 +28,47 @@ public class Parser {
28
28
* @return Returns boolean variable to indicate when to stop parsing for input.
29
29
* @throws DukeException if input is not valid.
30
30
*/
31
- public static boolean parse (String input , TaskList tasklist , Ui ui , Storage storage ){
31
+ public static boolean parse (String input , TaskList tasklist , Ui ui , Storage storage ) {
32
32
try {
33
- if (IsBye (input )) {
33
+ if (isBye (input )) {
34
34
//print bye message
35
- ui .ByeMessage ();
35
+ ui .byeMessage ();
36
36
ui .getIn ().close ();
37
37
return true ;
38
38
39
- } else if (IsList (input )) {
39
+ } else if (isList (input )) {
40
40
//print out current list
41
- ui .PrintList (tasklist , "list" );
41
+ ui .printList (tasklist , "list" );
42
42
43
- } else if (IsDone (input )) {
44
- ProcessDone (input , tasklist , ui );
43
+ } else if (isDone (input )) {
44
+ processDone (input , tasklist , ui );
45
45
46
- } else if (IsDeadline (input )) {
47
- ProcessDeadline (input , tasklist , ui );
48
- storage .save (tasklist .ReturnArrayList ());
46
+ } else if (isDeadline (input )) {
47
+ processDeadline (input , tasklist , ui );
48
+ storage .save (tasklist .returnArrayList ());
49
49
50
- } else if (IsTodo (input )) {
51
- ProcessTodo (input , tasklist , ui );
52
- storage .save (tasklist .ReturnArrayList ());
50
+ } else if (isTodo (input )) {
51
+ processTodo (input , tasklist , ui );
52
+ storage .save (tasklist .returnArrayList ());
53
53
54
- } else if (IsEvent (input )) {
55
- ProcessEvent (input , tasklist , ui );
56
- storage .save (tasklist .ReturnArrayList ());
54
+ } else if (isEvent (input )) {
55
+ processEvent (input , tasklist , ui );
56
+ storage .save (tasklist .returnArrayList ());
57
57
58
- } else if (IsDelete (input )) {
59
- ProcessDelete (input , tasklist , ui );
60
- storage .save (tasklist .ReturnArrayList ());
58
+ } else if (isDelete (input )) {
59
+ processDelete (input , tasklist , ui );
60
+ storage .save (tasklist .returnArrayList ());
61
61
62
- } else if (IsFind (input )) {
63
- ProcessFind (input , tasklist , ui );
62
+ } else if (isFind (input )) {
63
+ processFind (input , tasklist , ui );
64
64
65
65
} else {
66
- throw new DukeException (" \u2639 OOPS!!! I'm sorry, but I don't know what that means :-(" );
66
+ throw new DukeException (" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(" );
67
67
68
68
}
69
69
70
- }
71
- catch (DukeException e ){
72
- ui .ExceptionMessage (e .getMessage ());
70
+ } catch (DukeException e ) {
71
+ ui .exceptionMessage (e .getMessage ());
73
72
return true ;
74
73
}
75
74
@@ -82,19 +81,18 @@ public static boolean parse(String input, TaskList tasklist, Ui ui, Storage stor
82
81
* @param tasklist Tasklist of the user.
83
82
* @param ui Ui that interacts with the user.
84
83
*/
85
- private static void ProcessFind (String input , TaskList tasklist , Ui ui ){
86
- try {
84
+ private static void processFind (String input , TaskList tasklist , Ui ui ) {
85
+ try {
87
86
TaskList findlist = new TaskList ();
88
87
String [] splitspace = input .split (" " , 2 );
89
- for (Task tasks : tasklist .ReturnArrayList ()){
90
- if (tasks .getDescription ().contains (splitspace [1 ])){
91
- findlist .AddTask (tasks );
88
+ for (Task tasks : tasklist .returnArrayList ()) {
89
+ if (tasks .getDescription ().contains (splitspace [1 ])) {
90
+ findlist .addTask (tasks );
92
91
}
93
92
}
94
- ui .PrintList (findlist , "find" );
95
- }
96
- catch (ArrayIndexOutOfBoundsException e ) {
97
- ui .ExceptionMessage (" \u2639 OOPS!!! The content to find cannot be empty." );
93
+ ui .printList (findlist , "find" );
94
+ } catch (ArrayIndexOutOfBoundsException e ) {
95
+ ui .exceptionMessage (" ☹ OOPS!!! The content to find cannot be empty." );
98
96
}
99
97
}
100
98
@@ -104,16 +102,16 @@ private static void ProcessFind(String input, TaskList tasklist, Ui ui){
104
102
* @param tasklist Tasklist of the user.
105
103
* @param ui Ui that interacts with the user.
106
104
*/
107
- private static void ProcessDelete (String input , TaskList tasklist , Ui ui ){
108
- try {
105
+ private static void processDelete (String input , TaskList tasklist , Ui ui ) {
106
+ try {
109
107
String [] arr = input .split (" " , 2 );
110
108
int numdelete = Integer .parseInt (arr [1 ]) - 1 ;
111
- String task = tasklist .get (numdelete ).GiveTask ();
112
- tasklist .DeleteTask (numdelete );
113
- ui .PrintDeleteMessage (task , tasklist );
109
+ String task = tasklist .get (numdelete ).giveTask ();
110
+ tasklist .deleteTask (numdelete );
111
+ ui .printDeleteMessage (task , tasklist );
114
112
115
- }catch (ArrayIndexOutOfBoundsException e ){
116
- ui .ExceptionMessage (" \u2639 OOPS!!! Please input the list number to delete." );
113
+ } catch (ArrayIndexOutOfBoundsException e ) {
114
+ ui .exceptionMessage (" ☹ OOPS!!! Please input the list number to delete." );
117
115
}
118
116
}
119
117
@@ -123,15 +121,15 @@ private static void ProcessDelete(String input, TaskList tasklist, Ui ui){
123
121
* @param tasklist Tasklist of the user.
124
122
* @param ui Ui that interacts with the user.
125
123
*/
126
- private static void ProcessDone (String input , TaskList tasklist , Ui ui ){
127
- try {
124
+ private static void processDone (String input , TaskList tasklist , Ui ui ) {
125
+ try {
128
126
String [] arr = input .split (" " , 2 );
129
127
int numdone = Integer .parseInt (arr [1 ]) - 1 ;
130
- tasklist .get (numdone ).SetDone ();
131
- ui .PrintDoneMessage (numdone , tasklist );
128
+ tasklist .get (numdone ).setDone ();
129
+ ui .printDoneMessage (numdone , tasklist );
132
130
133
- }catch (ArrayIndexOutOfBoundsException e ){
134
- ui .ExceptionMessage (" \u2639 OOPS!!! Please input the list number to indicate as done." );
131
+ } catch (ArrayIndexOutOfBoundsException e ) {
132
+ ui .exceptionMessage (" ☹ OOPS!!! Please input the list number to indicate as done." );
135
133
}
136
134
}
137
135
@@ -141,7 +139,7 @@ private static void ProcessDone(String input, TaskList tasklist, Ui ui){
141
139
* @param tasklist Tasklist of the user.
142
140
* @param ui Ui that interacts with the user.
143
141
*/
144
- private static void ProcessDeadline (String input , TaskList tasklist , Ui ui ){
142
+ private static void processDeadline (String input , TaskList tasklist , Ui ui ) {
145
143
try {
146
144
String [] splitspace = input .split (" " , 2 );
147
145
String [] splitslash = splitspace [1 ].split ("/" , 2 );
@@ -150,14 +148,12 @@ private static void ProcessDeadline(String input, TaskList tasklist, Ui ui){
150
148
String taskTime = splittime [1 ];
151
149
Date formattedtime = dataformat .parse (taskTime );
152
150
Deadline deadline = new Deadline (taskDescription , dataformat .format (formattedtime ));
153
- tasklist .AddTask (deadline );
154
- ui .PrintAddedMessage (deadline , tasklist );
155
- }
156
- catch (ArrayIndexOutOfBoundsException e ){
157
- ui .ExceptionMessage (" \u2639 OOPS!!! The description of a deadline cannot be empty." );
158
- }
159
- catch (ParseException e ){
160
- ui .ExceptionMessage (" \u2639 OOPS!!! Format of time is wrong." );
151
+ tasklist .addTask (deadline );
152
+ ui .printAddedMessage (deadline , tasklist );
153
+ } catch (ArrayIndexOutOfBoundsException e ) {
154
+ ui .exceptionMessage (" ☹ OOPS!!! The description of a deadline cannot be empty." );
155
+ } catch (ParseException e ) {
156
+ ui .exceptionMessage (" ☹ OOPS!!! Format of time is wrong." );
161
157
}
162
158
}
163
159
@@ -167,15 +163,14 @@ private static void ProcessDeadline(String input, TaskList tasklist, Ui ui){
167
163
* @param tasklist Tasklist of the user.
168
164
* @param ui Ui that interacts with the user.
169
165
*/
170
- private static void ProcessTodo (String input , TaskList tasklist , Ui ui ){
166
+ private static void processTodo (String input , TaskList tasklist , Ui ui ) {
171
167
try {
172
168
String [] splitspace = input .split (" " , 2 );
173
169
Todo todotoadd = new Todo (splitspace [1 ]);
174
- tasklist .AddTask (todotoadd );
175
- ui .PrintAddedMessage (todotoadd , tasklist );
176
- }
177
- catch (ArrayIndexOutOfBoundsException e ) {
178
- ui .ExceptionMessage (" \u2639 OOPS!!! The description of a todo cannot be empty." );
170
+ tasklist .addTask (todotoadd );
171
+ ui .printAddedMessage (todotoadd , tasklist );
172
+ } catch (ArrayIndexOutOfBoundsException e ) {
173
+ ui .exceptionMessage (" ☹ OOPS!!! The description of a todo cannot be empty." );
179
174
}
180
175
}
181
176
@@ -185,7 +180,7 @@ private static void ProcessTodo(String input, TaskList tasklist, Ui ui){
185
180
* @param tasklist Tasklist of the user.
186
181
* @param ui Ui that interacts with the user.
187
182
*/
188
- private static void ProcessEvent (String input , TaskList tasklist , Ui ui ){
183
+ private static void processEvent (String input , TaskList tasklist , Ui ui ) {
189
184
try {
190
185
String [] splitspace = input .split (" " , 2 );
191
186
String [] splitslash = splitspace [1 ].split ("/" , 2 );
@@ -194,47 +189,45 @@ private static void ProcessEvent(String input, TaskList tasklist, Ui ui){
194
189
String taskTime = splittime [1 ];
195
190
Date formattedtime = dataformat .parse (taskTime );
196
191
Event event = new Event (taskDescription , dataformat .format (formattedtime ));
197
- tasklist .AddTask (event );
198
- ui .PrintAddedMessage (event , tasklist );
199
- }
200
- catch (ArrayIndexOutOfBoundsException e ) {
201
- ui .ExceptionMessage (" \u2639 OOPS!!! The description of a event cannot be empty." );
202
- }
203
- catch (ParseException e ){
204
- ui .ExceptionMessage (" \u2639 OOPS!!! Format of time is wrong." );
192
+ tasklist .addTask (event );
193
+ ui .printAddedMessage (event , tasklist );
194
+ } catch (ArrayIndexOutOfBoundsException e ) {
195
+ ui .exceptionMessage (" ☹ OOPS!!! The description of a event cannot be empty." );
196
+ } catch (ParseException e ) {
197
+ ui .exceptionMessage (" ☹ OOPS!!! Format of time is wrong." );
205
198
}
206
199
}
207
200
208
201
209
- private static boolean IsBye (String input ){
202
+ private static boolean isBye (String input ) {
210
203
return input .equals ("bye" );
211
204
}
212
205
213
- private static boolean IsList (String input ){
206
+ private static boolean isList (String input ) {
214
207
return input .equals ("list" );
215
208
}
216
209
217
- private static boolean IsDone (String input ){
210
+ private static boolean isDone (String input ) {
218
211
return input .startsWith ("done" );
219
212
}
220
213
221
- private static boolean IsDeadline (String input ){
214
+ private static boolean isDeadline (String input ) {
222
215
return input .startsWith ("deadline" );
223
216
}
224
217
225
- private static boolean IsTodo (String input ){
218
+ private static boolean isTodo (String input ) {
226
219
return input .startsWith ("todo" );
227
220
}
228
221
229
- private static boolean IsEvent (String input ){
222
+ private static boolean isEvent (String input ) {
230
223
return input .startsWith ("event" );
231
224
}
232
225
233
- private static boolean IsDelete (String input ){
226
+ private static boolean isDelete (String input ) {
234
227
return input .startsWith ("delete" );
235
228
}
236
229
237
- private static boolean IsFind (String input ){
230
+ private static boolean isFind (String input ) {
238
231
return input .startsWith ("find" );
239
232
}
240
233
}
0 commit comments