Write a system that tracks the top five scores for a game. The system has a list of five items, and each item has a name and the corresponding score. Initially, the list consists of five items with the name Anonymous and the score of 0. The system supports four commands: add, cut, show, exit.
The command show displays the name and the score of the top five players in the descending order of scores.
The command exit terminates the system.
The command add takes a score and a name from the user. The score is assumed to be within the range of 1 and 99. If the entered score is greater than or equal to any of the top five socres, it will be added to the list, and the lowest score will be removed. If not, the list remains unchanged.
The cut command enables the user to input a score. All leaderboard entries with scores less than or equal to the entered score are removed. For each removed entry, a new entry with
Name: Anonymous, Score: 0
is appended to the end of the leaderboard so that the total remains five entries.
If the entered score is smaller than all scores on the leaderboard, no changes will be made.
This system does not record items that are not in the leaderboard. For example, suppose an item has been entered, and this item is not added to the leaderboard. Then, this item is discarded and will not be used in the future.
A complete example is given below.
Enter commands (add, cut, show, exit):
add 68 Lily
add 25 Emma
add 25 Aria
add 71 Elizabeth
show
The top five scores are:
1. Elizabeth, Score: 71
2. Lily, Score: 68
3. Aria, Score: 25
4. Emma, Score: 25
5. Anonymous, Score: 0
cut 68
show
The top five scores are:
1. Elizabeth, Score: 71
2. Anonymous, Score: 0
3. Anonymous, Score: 0
4. Anonymous, Score: 0
5. Anonymous, Score: 0
exit
Your solution should be based on the code template.
Your program must conform the following requirements:
The output of your program should match the example provided exactly.
Add your code only within the function definitions of add_item() and cutoff_item()
Do not modify initialize_system(), display_items(), and interactive_test().
Input-output samples:
Suggestion:
Use the functions defined in the vector library to finish this assignment, e.g. insert(), pop_back(), erase(), push_back()
Use scores.at(i) instead of scores[i]
Test all the input-output samples before sending your solution.