Problem

Write a class that tracks the five highest scores for a game. The scores should be stored...

Write a class that tracks the five highest scores for a game. The scores should be stored in a file and include the player’s name as a string and the player’s score as an integer. The list of top scores should initially consist of the name Anonymous and scores of 0. The class should support the following functions:

■ A way to output to the screen the name and score of the top five players. The scores should be listed in order, with the highest score first and the lowest score last.

■ A function that takes a new name and score. If the score is higher than any of the top five scores then it should be added to the file and the lowest score discarded. Otherwise, the top list should remain unchanged.

Include an appropriate constructor or destructor if necessary, along with any helper functions. Write a main function that tests your class by simulating several score entries and outputting the high score list.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12