Write a class that keeps track of the top five high scores that could be used fo
ID: 3565928 • Letter: W
Question
Write a class that keeps track of the top five high scores that could be used for a video game. Internally, the class should store the top scores in a data structure of your choice (the most straight forward way is to use arrays). Each entry consists of a name and a score. The data stored in memory should be synchronized with a text file for persistent storage. For example, here are the contents of a sample file where Ronaldo has the highest score and Pele has the third lowest score:
Ronaldo
10400
Didier
9800
Pele
9750
Kaka
8400
Cristiano
8000
The constructor should test if the file exists. If it does not exist, then the file should be created with blank names for each of the players and a score of 0. If the file does exist, then the data from the file should be read into the class's instance variables. Along with appropriate constructors, accessors and mutators, add the following methods:
Explanation / Answer
Here is what I solved before, please modify the figures as per your question. Please let me know if you have further questions. Ifthis helps then kindly rate 5-stars.
Write a class that keeps track of the top five high scores that could be used for a video game. Internally, the class should store the top score in a data structure of your choice (the most straightforwar way is to use arrays). Each entry consists of a name and a score. The data stored in memory should be synchronized with a text file for persistent storage. For example, here are the contents of a sample file where Ronaldo has the highest score and Pele has the third highest score: Ronaldo 10400 Didier 9800 Pele 9750 Kaka 8400 Cristiano 8000 The constructor should test if the file exists. If it does not exist, then the file should be created with blank names for each of the players and a score of 0. If the file does exist, then the data from the file should be read into the class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.