Question: Load Player Contents Check ( 0 / 4 ) Rogue Class Creation ( 1 / 1 ) Rogue Class Display ( 0 / 1 )
Load Player Contents Check
Rogue Class Creation
Rogue Class Display
Save Player Contents Check
Sort NPC List not Full
Sort NPC List Full
Update Level Check
Warrior Class Creation
Warrior Class Display
Wizard Class Creation
Wizard Class Display
Add More Than One Player
Add Player Empty List
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
Note: It will tell you something like "Test Failed: b b where the left hand side is my output and the right hand side is the expected output.
this is my code:
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
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
