From 2af7a0f32afcf57e7aa2c3c848f77e16d194c1dc Mon Sep 17 00:00:00 2001 From: Chong Chee Yuan <32454748+ccyccyccy@users.noreply.github.com> Date: Tue, 21 Jan 2020 01:44:35 +0800 Subject: [PATCH] Fix issue where modules with only sem2 lessons are interpreted as error (#251) --- .../seedu/address/model/timetable/TimetableInput.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/model/timetable/TimetableInput.java b/src/main/java/seedu/address/model/timetable/TimetableInput.java index 1bec690d54e..6510dfb7419 100644 --- a/src/main/java/seedu/address/model/timetable/TimetableInput.java +++ b/src/main/java/seedu/address/model/timetable/TimetableInput.java @@ -89,8 +89,14 @@ private List getTimeRangesForModule(String moduleCode, List g */ private List getTimeRangeFromEntry(JsonNode moduleNode, String group, String lessonType, int sem, String moduleCode) throws IllegalValueException, JsonProcessingException { List targets = new ArrayList<>(); + int semIndex; + if(moduleNode.path("semesterData").path(0).path("semester").asInt() == 1) { + semIndex = sem - 1; + } else { + semIndex = sem - 2; + } moduleNode.path("semesterData") - .path(sem - 1) // Sem 1 + .path(semIndex) // Sem 1 .path("timetable") .forEach(node -> { if (node.path("classNo").asText().equals(group) && node.path("lessonType").asText().equals(lessonType)) {