Class TaskList
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a newDeadlinetask to the task list.static voidAdds a newEventtask to the task list.static voidAdds a newToDotask to the task list.static voiddeleteTask(int index) Deletes a task from the task list based on the provided index.Returns the current saved Task Liststatic voidmarkDone(int index, boolean status) Marks a task as complete or incomplete based on the provided index.static voidResets the task list by clearing all tasks.
-
Field Details
-
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
Returns the current saved Task List- Returns:
- The current saved Task List
-
addDeadline
Adds a newDeadlinetask 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- theDeadlinetask to add; must not benull.- Throws:
AmadeusException- if an error occurs while saving the updated list to the database.
-
addEvent
Adds a newEventtask 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- theEventtask to add; must not benull.- Throws:
AmadeusException- if an error occurs while saving the updated list to the database.
-
addToDo
Adds a newToDotask 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- theToDotask to add; must not benull.- Throws:
AmadeusException- if an error occurs while saving the updated list to the database.
-
markDone
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
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
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.
-