Question: Failed Tests Add More Than One Player ( ( 0 ) / ( 2 . 5 ) ) Add Player Empty List ( ( 0

Failed Tests
Add More Than One Player ((0)/(2.5))
Add Player Empty List ((0)/(2.5))
Load Player Contents Check ((0)/(4))
Rogue Class Display ((0)/(1))
Update Level Check ((0)/(2))
Warrior Class Display ((0)/(1))
Wizard Class Display ((0)/(1))
the error is:
- Add More Than One Player ((0)/(2.5))
Test Failed: b'CSE[1484 chars]lth: 1400
Mana:280
Armor: 1400
Magic Resist[592 chars]
'!= b'CSE[1484 chars]lth: 2800
Mana: 280
Armor: 1400
Magic Resis[617 chars]
- Add Player Empty List ((0)/(2.5))
Test Failed: b'CSE[688 chars]lth: 280
Mana:2800
Armor: 280
Magic Resist:[327 chars]
'!= b'CSE[688 chars]lth: 700
Mana: 2800
Armor: 280
Magic Resist[335 chars]
'
-Load Player Contents Check ((0)/(4))
Test Failed: b'CSE[289 chars]lth: 2350
Mana:470
Armor: 2350
Magic Resist[596 chars]
'!= b'CSE[289 chars]lth: 4700
Mana: 470
Armor: 2350
Magic Resis[620 chars]
'
-Rogue Class Display ((0)/(1))
Test Failed: b'Tes[48 chars]lth: 200
Mana:50
Armor: 50
Magic Resist:(20)/(52 chars):2
'!= b'Tes[48 chars]lth: 100
Mana: 50
Armor: 50
Magic Resist: 2[59 chars]ue
'
-Update Level Check ((0)/(2))
Test Failed: b'CSE[688 chars]lth: 5600
Mana:1400
Armor: 1400
Magic Resis[1061 chars]
'!= b'CSE[688 chars]lth: 2800
Mana: 1400
Armor: 1400
Magic Resi[1075 chars]
'
-Warrior Class Display ((0)/(1))
Test Failed: b'Tes[53 chars]lth: 2100
Mana:420
Armor: 2100
Magic Resist[60 chars]:0
'!= b'Tes[53 chars]lth: 4200
Mana: 420
Armor: 2100
Magic Resis[69 chars]or
'
- Wizard Class Display ((0)/(1))
Test Failed: b'Tes[51 chars]lth: 990
Mana:9900
Armor: 990
Magic Resist:[59 chars]:1
'!= b'Tes[51 chars]lth: 2475
Mana: 9900
Armor: 990
Magic Resis[68 chars]rd
'
-->It will tell you something like "Test Failed: b"..."!= b"..."" where the left hand side is your output and the right hand side is the expected output.
help me fix code below
// Q7-b: Define Friend Function updateLevel()(1.5 points)
// Define the function updateLevel()that is declared in player.h file.
// This function sets the new 'level' of the player. The player object and new level is to be passed as function arguments.
// Use 'd' display option after using 'c' option to verify.
// You will need to implement addPlayer() and displayList() before you test this function.
// Updating a player's level will update their stats. This scaling matches the same scaling as the constructor in player.cpp.
void updateLevel(Player* player, int newLevel){
player->level = newLevel;
// Update stats based on player type
if (player->getPlayerType()== warrior){
player->health = newLevel *200;
player->mana = newLevel *10;
player->armor = newLevel *50;
player->magicResist = newLevel *25;
player->attack = newLevel *50;
player->magicAttack = newLevel *10;
}
else if (player->getPlayerType()== wizard){
player->health = newLevel *25;
player->mana = newLevel *100;
player->armor = newLevel *10;
player->magicResist = newLevel *50;
player->attack = newLevel *10;
player->magicAttack = newLevel *100;
}
else if (player->getPlayerType()== rogue){
player->health = newLevel *50;
player->mana = newLevel *25;
player->armor = newLevel *25;
player->magicResist = newLevel *10;
player->attack = newLevel *100;
player->magicAttack = newLevel *50;
}
}
// Q8- addPlayer (5 points)
// This function is used to add a new player to the global linked list 'list'. Add the new player to tail of the list.
// playerType 'type' can be warrior, wizard, or rogue. You will need to use the function argument type to determine which constructor to use to create new player node.
// For example, if the user enters type as 'rogue', then you need to use the Rogue class and constructor to create new player node and add it to the list.
// NOTE: In executeAction(), searchPlayer() is called before this function. Therefore no need to check here if the player exists in the list.
// See how this fucntion is called in case 'a' of executeAction()
void addPlayer(string nameInput, int levelInput, playerType archetypeInput)
{
Player* newPlayer = nullptr;
// Create the correct subclass based on the archetype
switch (archetypeInput){
case warrior:
newPlayer = new Warrior(nameInput, levelInput, archetypeInput);
break;
case wizard:
newPlayer = new Wizard(nameInput, levelInput, archetypeInput);
break;
case rogue:
newPlayer = new Rogue(nameInput, levelInput, archetypeInput);
break;
default:
std::cerr << "Error: Invalid player type." << std::endl;
return; // Exit if archetype is invalid
}
// Create a new Container node and add it to the list
Container* newNode = new Container;
newNode->player = newPlayer; // Assign the new player to the node
newNode->next = nullptr; // Initialize the next pointer to nullptr
// If the list is empty, set the new node as the head
if (list == nullptr){
list = newNode;
}
else {
// Traverse to the end of the list
Container* tempList = list;
while (tempList->next != nullptr){
tempList = tempList->next; // Move to the next node
}
tempList->next = newNode; // Add the new node at the end
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!