Class TaskList

java.lang.Object
amadeus.workspace.TaskList

public class TaskList extends Object
Manages the list of tasks in the Amadeus application.

This class provides methods to add, mark, delete, and reset tasks, ensuring that changes are saved to the database and communicated to the user via speech.

  • Field Details

    • taskList

      public static ArrayList<Task> taskList
      ArrayList to store all tasks, categorized by type (Deadline, Event, ToDo, etc.). The list is initialized by loading tasks from the database when the program starts.
  • Constructor Details

    • TaskList

      public TaskList()
  • Method Details

    • getTaskList

      public static ArrayList<Task> getTaskList()
      Returns the current saved Task List
      Returns:
      The current saved Task List
    • addDeadline

      public static void addDeadline(Deadline d) throws AmadeusException
      Adds a new Deadline task to the task list.

      The task is inserted at the end of the Deadline section, and the updated list is saved to the database. The user is notified via speech that the task has been added.

      Parameters:
      d - the Deadline task to add; must not be null.
      Throws:
      AmadeusException - if an error occurs while saving the updated list to the database.
    • addEvent

      public static void addEvent(Event e) throws AmadeusException
      Adds a new Event task to the task list.

      The task is inserted at the end of the Event section, and the updated list is saved to the database. The user is notified via speech that the task has been added.

      Parameters:
      e - the Event task to add; must not be null.
      Throws:
      AmadeusException - if an error occurs while saving the updated list to the database.
    • addToDo

      public static void addToDo(ToDo td) throws AmadeusException
      Adds a new ToDo task to the task list.

      The task is inserted at the end of the ToDo section, and the updated list is saved to the database. The user is notified via speech that the task has been added.

      Parameters:
      td - the ToDo task to add; must not be null.
      Throws:
      AmadeusException - if an error occurs while saving the updated list to the database.
    • markDone

      public static void markDone(int index, boolean status) throws AmadeusException
      Marks a task as complete or incomplete based on the provided index.

      The updated task status is saved to the database, and the user is notified via speech.

      Parameters:
      index - the index of the task to update (1-based).
      status - the new completion status (true for complete, false for incomplete).
      Throws:
      AmadeusException - if the index is invalid or an error occurs while saving the updated list.
    • deleteTask

      public static void deleteTask(int index) throws AmadeusException
      Deletes a task from the task list based on the provided index.

      The updated list is saved to the database, and the user is notified via speech.

      Parameters:
      index - the index of the task to delete (1-based).
      Throws:
      AmadeusException - if the index is invalid or an error occurs while saving the updated list.
    • resetList

      public static void resetList() throws AmadeusException
      Resets the task list by clearing all tasks.

      This method removes all tasks from the task list, saves the updated (empty) list to the database, and notifies the user via speech that the task list has been reset.

      Throws:
      AmadeusException - if an error occurs while saving the updated list to the database.