Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Correct the following code To meet the specified requirements in the comments. Note: the TakingTurnsQueue.cs file should not be edited public static class TakingTurns {

Correct the following code
To meet the specified requirements in the comments. Note: the TakingTurnsQueue.cs file should not be edited
public static class TakingTurns
{
public static void Test()
{
// TODO Problem 1- Run test cases and fix the code to match requirements
// Test Cases
// Test 1
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (5), Sue (3) and
// run until the queue is empty
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, Sue, Tim, Tim
Console.WriteLine("Test 1");
var players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",5);
players.AddPerson("Sue",3);
Console.WriteLine(players); // This can be un-commented out for debug help
while (players.Length >0)
players.GetNextPerson();
// Defect(s) Found: mishandling of the players. players did not display in expected order.
Console.WriteLine("---------");
// Test 2
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (5), Sue (3)
// After running 5 times, add George with 3 turns. Run until the queue is empty.
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, George, Sue, Tim, George, Tim, George
Console.WriteLine("Test 2");
players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",5);
players.AddPerson("Sue",3);
for (int i =0; i <5; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
players.AddPerson("George",3);
// Console.WriteLine(players);
while (players.Length >0)
players.GetNextPerson();
// Defect(s) Found:
Console.WriteLine("---------");
// Test 3
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (Forever), Sue (3)
// Run 10 times.
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, Sue, Tim, Tim
Console.WriteLine("Test 3");
players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",0);
players.AddPerson("Sue",3);
// Console.WriteLine(players);
for (int i =0; i <10; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
// Defect(s) Found:
Console.WriteLine("---------");
// Test 4
// Scenario: Create a queue with the following people and turns: Tim (Forever), Sue (3)
// Run 10 times.
// Expected Result: Tim, Sue, Tim, Sue, Tim, Sue, Tim, Tim, Tim, Tim
Console.WriteLine("Test 4");
players = new TakingTurnsQueue();
players.AddPerson("Tim",-3);
players.AddPerson("Sue",3);
// Console.WriteLine(players);
for (int i =0; i <10; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
// Defect(s) Found:
Console.WriteLine("---------");
// Test 5
// Scenario: Try to get the next person from an empty queue
// Expected Result: Error message should be displayed
Console.WriteLine("Test 5");
players = new TakingTurnsQueue();
players.GetNextPerson();
// Defect(s) Found:
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions