/** This method clears the entire list of tasks */
 public void clearAll() {
   ArrayList<Task> taskList;
   if (isViewModeComplete()) {
     taskList = modifier.getCompleteContentList();
     taskList.clear();
     updateCompleteListFile(taskList);
     LoggingLogic.logging(CLEAR_VALID);
   } else {
     taskList = modifier.getContentList();
     taskList.clear();
     updateFile(taskList);
     LoggingLogic.logging(CLEAR_VALID);
   }
 }
  /**
   * This method removes a task from the current list
   *
   * @param index the line number of the task to be removed
   */
  public void removeTask(int index) {
    assert index >= 0;

    ArrayList<Task> taskList;
    if (isViewModeComplete()) {
      taskList = modifier.getCompleteContentList();
      taskList.remove(index);
      updateCompleteListFile(taskList);
      LoggingLogic.logging(DELETE_VALID);
    } else {
      taskList = modifier.getContentList();
      taskList.remove(index);
      updateFile(taskList);
      LoggingLogic.logging(DELETE_VALID);
    }
  }
  /**
   * This method sends the task selected into the completed task list and removes it from the
   * current task list
   *
   * @param index the line index of the task to be moved
   */
  public void completeTask(int index) {
    ArrayList<Task> completedList = modifier.getCompleteContentList();
    ArrayList<Task> taskList = modifier.getContentList();
    Calendar calendar = Calendar.getInstance();

    Task completedTask = taskList.get(index);
    if (completedTask.getRepeat() == false) {
      completedTask.setComplete();
      completedList.add(0, completedTask);
      taskList.remove(index);
      updateFile(taskList);
      updateCompleteListFile(completedList);
    } else {
      if (completedTask.getStartDate() == null) {
        Date currentDeadline = completedTask.getEndDateInDateType();
        int repeatCycle = completedTask.getRepeatCycle();
        String repeatType = completedTask.getRepeatType();
        calendar.setTime(currentDeadline);
        Date nextDeadline = getNextDeadline(calendar, repeatCycle, repeatType);
        completedTask.setEndDateInDate(nextDeadline);
        taskList.set(index, completedTask);
        updateFile(taskList);
      } else {
        Date currentStartDate = completedTask.getStartDateInDateType();
        Date currentEndDate = completedTask.getEndDateInDateType();
        int repeatCycle = completedTask.getRepeatCycle();
        String repeatType = completedTask.getRepeatType();
        calendar.setTime(currentStartDate);
        Date nextStartDate = getNextDeadline(calendar, repeatCycle, repeatType);
        calendar.setTime(currentEndDate);
        Date nextEndDate = getNextDeadline(calendar, repeatCycle, repeatType);
        completedTask.setStartDateInDate(nextStartDate);
        completedTask.setEndDateInDate(nextEndDate);
        taskList.set(index, completedTask);
        updateFile(taskList);
      }
    }
  }