Question: The Taking_Turns_Queue class maintains a circular queue of people. When a person is added, they are assigned a number of turns (a value of 0
The Taking_Turns_Queue class maintains a circular queue of people. When a person is added, they are assigned a number of turns (a value of 0 or less means that they have an infinite number of turns). When a person is removed from the queue, they are re-added to the queue if they still have turns left. Here are the detailed requirements (which can not be changed):
- The add_person function shall enqueue a person into the queue.
- The get_next_person function shall dequeue a person from the queue and display their name.
- When a person is dequeued and still has turns left, they shall be enqueued again.
- When a person is dequeued and has an infinite number of turns (defined as having number of turns of 0 or less), they shall be enqueued again.
- If the queue is empty, then an error message shall be displayed.
python
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
