Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Taking Turns Queue Examine the following code file: TakingTurns.cs ( Note: Do not read through the referenced code first. Instead, proceed with the instructions below
Taking Turns Queue
Examine the following code file: TakingTurns.cs Note: Do not read through the referenced code first. Instead, proceed with the instructions below
The TakingTurnsQueue class maintains a circular queue of people. When a person is added, they are assigned a number of turns a value of or less means that they have an infinite number of turns When a person is removed from the queue, they are readded to the queue if they still have turns left. Here are the detailed requirements which cannot be changed:
The AddPerson function shall enqueue a person into the queue.
The GetNextPerson 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 or less they shall be enqueued again.
If the queue is empty, then an error message shall be displayed.
Test cases are already written for you in the code. Run the tests and find the errors.
Summarize the results of the tests and the errors found within the test case documentation underneath each test case.
Fix the code so that all requirements are implemented correctly. You know that you are done because the test cases will all pass.
Priority Queue
Examine the following code file: Priority.cs Note: Do not read through the referenced code first. Instead, proceed with the instructions below
The PriorityQueue class maintains a queue where each value put in the queue also has a priority higher numbers have a higher priority When you add to the queue, it goes to the back as expected. When you remove from the queue, the highest priority item is removed. If there are multiple values with the same high priority, then the first one following the FIFO strategy is removed first. Here are the detailed requirements which cannot be changed:
The Enqueue function shall add an item which contains both data and priority to the back of the queue.
The Dequeue function shall remove the item with the highest priority and return its value.
If there are more than one item with the highest priority, then the item closest to the front of the queue will be removed and its value returned.
If the queue is empty, then an error message will be displayed.
Write your own test cases based on these requirements within the test case documentation in Priority.cs Ensure that your tests cover all of the requirements listed above.
Run your test cases and find the errors. If your tests were not sufficient, you might not find all the errors in the code. You should summarize the results of the tests and the errors found within the test case documentation at the end of each test.
Fix the code so that all requirements are implemented correctly. You know that you are done because the test cases will all pass assuming your test cases were sufficient
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started