Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help with C++ Create a program that manages the statistics for a player of a game. Note: Bold words are output while non-bold words
Please help with C++
Create a program that manages the statistics for a player of a game. Note: Bold words are output while non-bold words are input in the following console sample. Console Sample Game Stats Manager COMMAND MENU s - Show all player names v - View a player's statistics a - Add a player d - Delete a player x - Exit program Command: 1 Invalid command. Try again. Command: s Michael James Bobby Green Command: v Enter a player name: Chris Paul Invalid player name. Command: v Enter a player name: Bobby Green Wins: 34 Losses: 34 Ties: 9 Command: a Enter the player name: Bobby Green Player already exists. Command: a Enter the player name: Chris Paul Enter the wins: 53 Bnter the losses: 23 Enter the ties: 5 Player added! Command: s Michael James Bobby Green Chris Paul Command: v Enter a player name: Chris Paul Wins: 53 Losses: 23 Ties: 5 Command: d Enter the player name: Chris Paul Player removed! Command: s Michael James Bobby Green Command: d Enter a player name: Chris Paul Invalid player name. Bye The stats.txt file (the 4 columns are name, wins, losses, and ties respectively, aligned with tabs) Specifications - "stats.txt" is a tab-delimited text file that contains the statistics of all the players. Each entry has the player's name (a string), wins (an integer), losses (an integer) and ties (an integer). - The program should create a structure named Player to store the player's name, wins, losses, and ties. - The program should create a vector of Player objects to store the data for each player. When the program starts, it should call a function named store players_in_vector to load the data from the file "stats.txt" into this vector. This vector must be a local variable of the main function. (Hint: use reference parameters in user-defined functions.) - Your program should call a function named displa__menu providing a menu of commands as shown in the console sample including showing all player names, viewing statistics of a specified player, adding a new player, removing a player and exiting the program. - Your program will keep asking for user's command until user types x or X. If an invalid command is received, the command menu will be displayed again besides an error message as shown in the Console Sample. - A function must be created for showing all player names, viewing statistics of a specified player, adding a new player and removing a player respectively. - You have to verify whether the player to be added already exists in the vector. Otherwise the operation will be aborted and an error message should be displayed as shown in the Console Sample. - You have to verify whether the player to be viewed or deleted does exist in the vector. Otherwise the operation will be aborted and an error message should be displayed as shown in the Console Sample. - Create another function save players to write the current contents from the vector back to the same file and it should be called within the functions for adding and removing a player as the last step so the change isn't lost if the program quits accidentally. - Player names should allow spaces. - Your program should be able to handle unexpected data in file. (Hint: use the stringstream class together with the ifstream class.)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started