Question: Failed Tests Add More Than One Player ( ( 0 ) / ( 2 . 5 ) ) Add Player Empty List ( ( 0
Failed Tests
Add More Than One Player
Add Player Empty List
Load Player Contents Check
Rogue Class Display
Update Level Check
Warrior Class Display
Wizard Class Display
the error is:
Add More Than One Player
Test Failed: b'CSE charslth:
Mana:
Armor:
Magic Resist chars
b'CSE charslth:
Mana:
Armor:
Magic Resis chars
Add Player Empty List
Test Failed: b'CSE charslth:
Mana:
Armor:
Magic Resist: chars
b'CSE charslth:
Mana:
Armor:
Magic Resist chars
Load Player Contents Check
Test Failed: b'CSE charslth:
Mana:
Armor:
Magic Resist chars
b'CSE charslth:
Mana:
Armor:
Magic Resis chars
Rogue Class Display
Test Failed: b'Tes charslth:
Mana:
Armor:
Magic Resist: chars:
b'Tes charslth:
Mana:
Armor:
Magic Resist: charsue
Update Level Check
Test Failed: b'CSE charslth:
Mana:
Armor:
Magic Resis chars
b'CSE charslth:
Mana:
Armor:
Magic Resi chars
Warrior Class Display
Test Failed: b'Tes charslth:
Mana:
Armor:
Magic Resist chars:
b'Tes charslth:
Mana:
Armor:
Magic Resis charsor
Wizard Class Display
Test Failed: b'Tes charslth:
Mana:
Armor:
Magic Resist: chars:
b'Tes charslth:
Mana:
Armor:
Magic Resis charsrd
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
Qb: Define Friend Function updateLevel points
Define the function updateLevelthat 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 updateLevelPlayer player, int newLevel
playerlevel newLevel;
Update stats based on player type
if playergetPlayerType warrior
playerhealth newLevel ;
playermana newLevel ;
playerarmor newLevel ;
playermagicResist newLevel ;
playerattack newLevel ;
playermagicAttack newLevel ;
else if playergetPlayerType wizard
playerhealth newLevel ;
playermana newLevel ;
playerarmor newLevel ;
playermagicResist newLevel ;
playerattack newLevel ;
playermagicAttack newLevel ;
else if playergetPlayerType rogue
playerhealth newLevel ;
playermana newLevel ;
playerarmor newLevel ;
playermagicResist newLevel ;
playerattack newLevel ;
playermagicAttack newLevel ;
Q addPlayer 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 addPlayerstring nameInput, int levelInput, playerType archetypeInput
Player newPlayer nullptr;
Create the correct subclass based on the archetype
switch archetypeInput
case warrior:
newPlayer new WarriornameInput levelInput, archetypeInput;
break;
case wizard:
newPlayer new WizardnameInput levelInput, archetypeInput;
break;
case rogue:
newPlayer new RoguenameInput 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;
newNodeplayer newPlayer; Assign the new player to the node
newNodenext 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 tempListnext nullptr
tempList tempListnext; Move to the next node
tempListnext 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
