#C13740. Interactive To‐Do List Manager

    ID: 43312 Type: Default 1000ms 256MiB

Interactive To‐Do List Manager

Interactive To‐Do List Manager

This problem requires you to implement an interactive to‐do list manager. You will maintain a list of tasks where each task has a title, a description, a deadline (in the format \(YYYY\text{-}MM\text{-}DD\)), and a status (either pending or completed). The system should support the following commands:

  • add: Add a new task. After the command, three lines follow: the task title, description, and deadline.
  • list: Display all tasks sorted in ascending order by deadline. Each task should be printed on a separate line in the format: {index}. {title} - Due: {deadline} - Status: {status}.
  • complete: Mark a task as completed. After this command, a line with the index (as shown in the sorted list) is provided.
  • delete: Delete a task. This command is followed by a line containing the index of the task (based on the sorted order).
  • quit: Terminates the program.

Additionally, before processing a command (especially before a list), your program must archive (i.e., remove) tasks whose deadlines are older than \(30\) days from the current system date. The comparison of dates should be performed using the standard \(YYYY\text{-}MM\text{-}DD\) format and \(\mathcal{O}(n)\) operations are acceptable.

inputFormat

The input is a series of lines representing commands and their arguments, read from standard input. The commands are:

  • add: Followed by three lines: title, description, and deadline (in YYYY-MM-DD format).
  • list: Prints the list of tasks.
  • complete: Followed by one line containing an integer index to mark as completed.
  • delete: Followed by one line containing an integer index to remove the task.
  • quit: Ends the program.

outputFormat

Whenever the list command is issued, output the tasks (after archiving old tasks) to standard output. Each task should be printed in one line with the format:

{index}. {title} - Due: {deadline} - Status: {status}

If an invalid command is entered, output Invalid action. Please try again. on a separate line.

## sample
add
Task1
Description1
2050-12-31
list
quit
0. Task1 - Due: 2050-12-31 - Status: pending

</p>