Skip to content

Commit

Permalink
Merge pull request #231 from TehZiHuai/master
Browse files Browse the repository at this point in the history
bugfixes on logic and ui
  • Loading branch information
TehZiHuai authored Nov 10, 2019
2 parents c5986ef + 75de2ea commit 36b9440
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/main/java/Operations/CheckAnomaly.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public static Boolean checkDuplicateOverdue(Task task) {
String assignee = task.getAssignee();
String date = task.getDate().toString();
ArrayList<Task> 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;
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/Operations/OverdueList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Operations/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/RoomShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 36b9440

Please sign in to comment.