#C5687. ToDo List Manager
ToDo List Manager
ToDo List Manager
You are given a ToDo List Manager which supports three operations:
- ADD <task>: Adds a task named
task
to the list. Duplicate tasks are ignored. If the list already contains 100 tasks, output an error message:Task list is full
. - REMOVE <task>: Removes the task from the list. If the task does not exist, output an error message:
Task not found
. - GET: Outputs the list of tasks in the order they were added, joined by a comma and a space. If the list is empty, output an empty line.
Implement the ToDo List Manager and process a sequence of commands from standard input. Note that exceptions should be handled by printing the error message to standard output.
In mathematical terms, let \(T\) be the set of tasks. The operations satisfy:
ADD(task)
: If \(task \notin T\) and \(|T| < 100\), then \(T = T \cup \{task\}\).REMOVE(task)
: If \(task \in T\), then \(T = T \setminus \{task\}\); otherwise, an error occurs.GET()
: Returns the tasks in the order they were added.
inputFormat
The first line of input contains an integer \(Q\) - the number of commands. The following \(Q\) lines each contain a command in one of the following formats:
ADD <task>
REMOVE <task>
GET
Note that <task>
may contain spaces.
outputFormat
For each command, your program should behave as follows:
ADD
: No output unless the task list is full, in which case outputTask list is full
.REMOVE
: No output if successful; if the task does not exist, outputTask not found
.GET
: Output the current list of tasks joined by a comma and a space. If the list is empty, output an empty line.
6
ADD Buy groceries
ADD Buy groceries
GET
REMOVE Buy groceries
GET
REMOVE Buy groceries
Buy groceries
Task not found
</p>