diff --git a/src/main/java/Operations/CheckAnomaly.java b/src/main/java/Operations/CheckAnomaly.java index 62be2b7dd6..475bb9f6c6 100644 --- a/src/main/java/Operations/CheckAnomaly.java +++ b/src/main/java/Operations/CheckAnomaly.java @@ -42,11 +42,11 @@ public static Boolean checkDuplicateOverdue(Task task) { String assignee = task.getAssignee(); String date = task.getDate().toString(); ArrayList temp = OverdueList.getOverdueList(); - for (int i = 0; i < temp.size(); i++) { - if (temp.get(i).getDescription().equals(name) - && temp.get(i).getAssignee().equals(assignee) - && temp.get(i).getDate().toString().equals(date) - && temp.get(i).getClass().equals(task.getClass())) { + for (Task value : temp) { + if (value.getDescription().equals(name) + && value.getAssignee().equals(assignee) + && value.getDate().toString().equals(date) + && value.getClass().equals(task.getClass())) { return true; } } diff --git a/src/main/java/Operations/OverdueList.java b/src/main/java/Operations/OverdueList.java index e98de7431b..f62d24e2bb 100644 --- a/src/main/java/Operations/OverdueList.java +++ b/src/main/java/Operations/OverdueList.java @@ -38,25 +38,25 @@ public void add(Task task) { public void reschedule(int[] idx, TaskList taskList) throws RoomShareException { int[] index = idx.clone(); if (index.length ==1) { - if (index[0] < 0 || index[0] >= Overdue.size()) { + if (index[0] < 0 || index[0] >= overdue.size()) { System.out.println("This are your tasks in your Overdue list"); list(); throw new RoomShareException(ExceptionType.outOfBounds); } else { - taskList.add(Overdue.get(index[0])); - Overdue.get(index[0]).setOverdue(false); + taskList.add(overdue.get(index[0])); + overdue.get(index[0]).setOverdue(false); } } else { - if (index[0] < 0 || index[0] >= Overdue.size() || index[1] < 0 || index[1] >= Overdue.size()) { + if (index[0] < 0 || index[0] >= overdue.size() || index[1] < 0 || index[1] >= overdue.size()) { throw new RoomShareException(ExceptionType.outOfBounds); } for (int i = index[0]; i <= index[1]; i++){ - taskList.add(Overdue.get(i)); - Overdue.get(i).setOverdue(false); + taskList.add(overdue.get(i)); + overdue.get(i).setOverdue(false); } } for (int i = 0; i < index.length; i++){ - Overdue.removeIf(n -> !n.getOverdue()); + overdue.removeIf(n -> !n.getOverdue()); } } diff --git a/src/main/java/Operations/TaskList.java b/src/main/java/Operations/TaskList.java index 56d29abde3..19d77cf4fd 100644 --- a/src/main/java/Operations/TaskList.java +++ b/src/main/java/Operations/TaskList.java @@ -80,7 +80,7 @@ public void list(OverdueList overdueList) throws RoomShareException { for (int i = 0; i < tasks.size(); i++) { if (new Date().after(tasks.get(i).getDate()) && !(tasks.get(i) instanceof Leave)) { tasks.get(i).setOverdue(true); - if (CheckAnomaly.checkDuplicateOverdue(tasks.get(i))) { + if (!CheckAnomaly.checkDuplicateOverdue(tasks.get(i))) { // no duplicates in overdue list overdueList.add(tasks.get(i)); } diff --git a/src/main/java/RoomShare.java b/src/main/java/RoomShare.java index 529645bc4d..4eb819bf00 100644 --- a/src/main/java/RoomShare.java +++ b/src/main/java/RoomShare.java @@ -22,7 +22,6 @@ public class RoomShare { private TaskList taskList; private OverdueList overdueList; private Parser parser; - private RecurHandler recurHandler; private TempDeleteList tempDeleteList; private TaskCreator taskCreator; private Help help; @@ -32,7 +31,7 @@ public class RoomShare { * Constructor of a RoomShare class. Creates all necessary objects and collections for RoomShare to run * Also loads the ArrayList of tasks from the data.txt file */ - public RoomShare() throws RoomShareException { + private RoomShare() throws RoomShareException { ui = new Ui(); help = new Help(); ui.startUp(); @@ -57,7 +56,7 @@ public RoomShare() throws RoomShareException { overdueList = new OverdueList(emptyList); } listRoutine = new ListRoutine(taskList, overdueList); - recurHandler = new RecurHandler(taskList); + RecurHandler recurHandler = new RecurHandler(taskList); if (recurHandler.checkRecurrence()) { ui.showChangeInTaskList(); taskList.list(overdueList); @@ -68,7 +67,7 @@ public RoomShare() throws RoomShareException { /** * Deals with the operation flow of RoomShare. */ - public void run() throws RoomShareException, IOException, InterruptedException { + private void run() throws RoomShareException, IOException, InterruptedException { boolean isExit = false; while (!isExit) { TaskType type; @@ -408,7 +407,6 @@ public void run() throws RoomShareException, IOException, InterruptedException { } catch (RoomShareException e) { ui.showError(e); } - listRoutine.list(); } else { ui.showTagged(input); int[] doneArray = taskList.listTagged(input);