Question: write a c + + function: from a class: void update ( Player players [ ] , int num _ players ) This function will

write a c++ function: from a class: void update( Player players[], int num_players ) This function will read the game.txt file of data to update the array and produce a report of the updates. It takes as its arguments an array of Player objects to update, and an integer that holds the number of players in the array. It returns nothing. The function should start by declaring any variables that are needed. At a minimum, there should be an integer variable to hold the incoming integer value, a character variable to hold the incoming character value, a character array to hold the incoming string value, an integer to hold a subscript from the searching, and an input file stream. Display a title for the report that is produced by the function. Next, the function should attempt to open the input file and verify that it opened correctly. Now that the file has been opened correctly, it's time to read the information, one value at a time. Use the getline function described above to read the first player name from input file into a character array. In a loop that executes as long as there is information, read the remaining input values for the player (the statistic code and the change to the statistic), use the search function to determine if the player is in the array, apply the update or display an error message based on the result of the search, use the ignore function to clear the input file stream, and read the next player name from the input file. Finally, once all the data has been read from the file, close the file. The description mentions "apply the update or display an error message based on the result of the search. The possibilities are: The player is not found in the array of Player objects. Display an error message that indicates the player is not found. The message must include the name of the player. The player is found and the statistic code is 'G'. Call the changeGoals method for the player that was found to update their number of goals. Display a message that includes the player's name and the updated that was applied. The player is found and the statistic code is 'A'. Call the changeAssists method for the player that was found to update their number of assists. Display a message that includes the player's name and the updated that was applied. The player is found and the statistic code is invalid. Display an error message that includes the statistic code and that it is invalid.

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 Programming Questions!