Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Asuraxsoul committed Sep 18, 2020
1 parent 8d1f93b commit bb5c8ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String parseUserInput(String str) throws DukeException {
int commandSpace = str.indexOf(COMMAND_SEPARATOR);

if (trimmedStr.length() < MINIMUM_COMMAND_LENGTH) {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
throw new DukeException(exceptionCommand.getOutput());
}

Expand All @@ -65,7 +65,7 @@ public String parseUserInput(String str) throws DukeException {
return listCommand.getOutput();

} else if (commandSpace <= START) { //No space in user input
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
throw new DukeException(exceptionCommand.getOutput());
}

Expand Down Expand Up @@ -95,13 +95,13 @@ public String parseUserInput(String str) throws DukeException {
EventCommand eventCommand = new EventCommand(str, taskManager);
return eventCommand.getOutput();

} catch(DukeException de) {
} catch (DukeException de) {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_DATE_FORMAT);
throw new DukeException(exceptionCommand.getOutput());
}

} else if (commandSpace <= END_FIVE_CHARACTERS) {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
throw new DukeException(exceptionCommand.getOutput());
}

Expand All @@ -112,7 +112,7 @@ public String parseUserInput(String str) throws DukeException {
return deleteCommand.getOutput();

} else if (commandSpace <= END_SIX_CHARACTERS) {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
throw new DukeException(exceptionCommand.getOutput());
}

Expand All @@ -123,13 +123,13 @@ public String parseUserInput(String str) throws DukeException {
DeadlineCommand deadlineCommand = new DeadlineCommand(str, taskManager);
return deadlineCommand.getOutput();

} catch(DukeException de) {
} catch (DukeException de) {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_DATE_FORMAT);
throw new DukeException(exceptionCommand.getOutput());
}

} else {
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
ExceptionCommand exceptionCommand = new ExceptionCommand(ExceptionCommand.INVALID_COMMAND);
throw new DukeException(exceptionCommand.getOutput());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
public class TaskList {
private final String IMPOSSIBLE_DATE = "2000-01-01";
private final static String DATE_FORMAT = "MMM d yyyy";
private static final String DATE_FORMAT = "MMM d yyyy";

private List<Task> tasks;

Expand Down Expand Up @@ -82,13 +82,13 @@ public Task markDone(int index) {
*/
public LocalDate taskDateFormatter(Task currentTask, String taskType) {
if (taskType.equals(Task.EVENT_TASK)) {
Event currentEventTask = (Event)currentTask;
Event currentEventTask = (Event) currentTask;
String formattedTime = currentEventTask.getFormattedTime();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
return LocalDate.parse(formattedTime, dateFormatter);

} else if (taskType.equals(Task.DEADLINE_TASK)) {
Deadline currentDeadlineTask = (Deadline)currentTask;
Deadline currentDeadlineTask = (Deadline) currentTask;
String formattedTime = currentDeadlineTask.getFormattedTime();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
return LocalDate.parse(formattedTime, dateFormatter);
Expand Down

0 comments on commit bb5c8ba

Please sign in to comment.