Question: I want the same exact coding ( C + + ) in the first 4 pictures, but I want to add another option for the
I want the same exact codingC in the first pictures, but I want to add another option for the user which is to choose a weapon and save it to the file just like the last picture.Please use the same coding in the first pictures and consider these Specifications:
Add a new member to the GamePlayer structure which will be a string weapon to represent
the weapon that each player will use in the game
Create an array with a size of that will contain the available weapons to choose from. Set the
weapon choices to : Axe, Knife, Bow, Wand
Create a function called setweapons that will receive a vector of GamePlayer type in its
parameter. For this function:
Request the player number which will represent the player choosing a weapon. Make sure
the player number is valid, otherwise show an error message see console example for
reference
After receiving a valid player number display to the user all the weapons available.
Then, request the weapon name which will represent the weapon that the player will be
choosing. Make sure the weapon name is valid, otherwise show an error message see console
example for reference
After receiving a valid weapon name, save its weapon choice for the player selected and
display an appropriate message to the screen. see console example for reference
Finally call the addweaponstofile function in order to save the weapon choice for the
player on the weapons.txt file.
Create a function called addweaponstofile that will receive a vector of GamePlayer type,
and an int playerindex variable in its function parameters. For this function:
Write to a weapons.txt file in append mode that has the following format separated by tab
characters: Name of the player Occupation Weapon of choice see file example for
reference
After writing the new entry to the file, display an appropriate message to the screen see
console example for reference
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
