Skip to content

Commit

Permalink
Merge branch 'branch-A-CodingStandard'
Browse files Browse the repository at this point in the history
  • Loading branch information
junweimoo committed Sep 9, 2022
2 parents d081eed + 2d069b3 commit 5f24147
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
16 changes: 8 additions & 8 deletions src/main/java/duke/utils/InputParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ private boolean isTaskType(String s) {

private TaskType getTaskType(String type) {
switch(type) {
case "todo":
return TaskType.TODO;
case "event":
return TaskType.EVENT;
case "deadline":
return TaskType.DEADLINE;
default:
return null;
case "todo":
return TaskType.TODO;
case "event":
return TaskType.EVENT;
case "deadline":
return TaskType.DEADLINE;
default:
return null;
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/duke/utils/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ private static Task fromDataString(String dataString) {

try {
switch(arr[0]) {
case "[T]":
ret = new Todo(arr[2]);
break;
case "[D]":
ret = new Deadline(arr[2], DateParser.stringToDate(arr[3]));
break;
case "[E]":
ret = new Event(arr[2], DateParser.stringToDate(arr[3]));
break;
default:
return null;
case "[T]":
ret = new Todo(arr[2]);
break;
case "[D]":
ret = new Deadline(arr[2], DateParser.stringToDate(arr[3]));
break;
case "[E]":
ret = new Event(arr[2], DateParser.stringToDate(arr[3]));
break;
default:
return null;
}
} catch (UnrecognisedDateException e) {
return null;
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/duke/utils/TaskParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ public static Task stringToTask(TaskType type, String s)
String[] taskInfo;

switch (type) {
case TODO:
return new Todo(s);
case EVENT:
taskInfo = s.split("/at");
if (taskInfo.length < 2) {
throw new EmptyTaskDateException();
}
return new Event(taskInfo[0].trim(), DateParser.stringToDate(taskInfo[1].trim()));
case DEADLINE:
taskInfo = s.split("/by");
if (taskInfo.length < 2) {
throw new EmptyTaskDateException();
}
return new Deadline(taskInfo[0].trim(), DateParser.stringToDate(taskInfo[1].trim()));
default:
throw new NoSuchTaskTypeException(type.name());
case TODO:
return new Todo(s);
case EVENT:
taskInfo = s.split("/at");
if (taskInfo.length < 2) {
throw new EmptyTaskDateException();
}
return new Event(taskInfo[0].trim(), DateParser.stringToDate(taskInfo[1].trim()));
case DEADLINE:
taskInfo = s.split("/by");
if (taskInfo.length < 2) {
throw new EmptyTaskDateException();
}
return new Deadline(taskInfo[0].trim(), DateParser.stringToDate(taskInfo[1].trim()));
default:
throw new NoSuchTaskTypeException(type.name());
}
}

Expand Down

0 comments on commit 5f24147

Please sign in to comment.