package seedu.ezdo.commons.util;

import java.util.ArrayList;

import seedu.ezdo.commons.core.UnmodifiableObservableList;
import seedu.ezdo.model.todo.ReadOnlyTask;
import seedu.ezdo.model.todo.Task;
//@@author A0139248X
/**
 * Utility methods for commands supporting multiple index
 */
public class MultipleIndexCommandUtil {

    /** checks if the indexes specified are all smaller than the size of the list and not 0 i.e. valid */
    public static boolean isIndexValid(UnmodifiableObservableList<ReadOnlyTask> lastShownList,
            ArrayList<Integer> targetIndexes) {
        return targetIndexes.stream().allMatch(index -> index <= lastShownList.size() && index != 0);
    }

    /** adds read only tasks from the unmodifiable observable list to the ArrayList list */
    public static void addReadOnlyTasksToList(ArrayList<ReadOnlyTask> list,
            UnmodifiableObservableList<ReadOnlyTask> lastShownList, ArrayList<Integer> targetIndexes) {
        for (int i = 0; i < targetIndexes.size(); i++) {
            ReadOnlyTask readOnlyTask = lastShownList.get(targetIndexes.get(i) - 1);
            list.add(readOnlyTask);
        }
    }

    /** adds tasks from the unmodifiable observable list to the ArrayList list */
    public static void addTasksToList(ArrayList<Task> list,
            UnmodifiableObservableList<ReadOnlyTask> lastShownList, ArrayList<Integer> targetIndexes) {
        for (int i = 0; i < targetIndexes.size(); i++) {
            Task task = (Task) lastShownList.get(targetIndexes.get(i) - 1);
            list.add(task);
        }
    }
}

@@ -673,24 +673,541 @@
 != 0);%0A    %7D
+%0A    %0A    //@@author A0139177W%0A    /** checks if the tasks with the indexes specified are marked as done */%0A    public static boolean isDone(UnmodifiableObservableList%3CReadOnlyTask%3E lastShownList,%0A            ArrayList%3CInteger%3E targetIndexes) %7B%0A        for (int i = 0; i %3C targetIndexes.size(); i++) %7B%0A            Task task = (Task) lastShownList.get(targetIndexes.get(i) - 1);%0A            if (task.getDone()) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A    //@@author A0139177W
 %0A%0A    /** ad

Add isDone method to check if a task is done