Write a class that keeps track of the top five high scores

Assignment Help Computer Engineering
Reference no: EM132196996

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 straightforward 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:

Score.txt

Ronado
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:

void playerScore(String name, int score) : Whenever a game is over, the method is called with the player's name and final score. If the name is one of the top five, then it should be added to the list and lowest score should dropped out. If the score is not in the top five, then nothing happens.

String [] getTopNames() : Returns an array of the names of the top players, with the top player first, the second highest score second, etc.

int [] getTopScores() : Returns an array of the scores of the top players, with the highest score first, the second highest score second, etc.

Test your program with several calls to playerScore() method and print out the list of top names and scores to ensure that the correct values are stored. When the program is restarted, it should remember the top scores from the last session.

Reference no: EM132196996

Questions Cloud

Write a client program that connects to the server : Write a client program in C/C++ that connects to the server you wrote in problem.
Discuss an episode of government intervention : BFW2341 International Financial Management - Monash university - Evaluation of government intervention in the foreign exchange market
Write a client class to test all your methods : Write a class encapsulating the concept of a Student, assuming that a student has the following attributes: last name, first name, id, array of grades.
Write a class encapsulating a music store which inherits : Write a class encapsulating a music store, which inherits from Store. A music store ahs the following additional attributes: the number of titles it offers.
Write a class that keeps track of the top five high scores : Write a class that keeps track of the top five high scores that could be used for a video game.
An instance variable named amount of type double : A method named useGas that accepts a parameter of type double . The value of the amount instance variable is decreased by the value of the parameter .
Calculates and returns the current income amount : Two (2) instance variables a double called "IncomeYTD" and double called "hourlyRate" The class should also include the following methods.
Write a client program that allows the user to pick one : Write a client program that allows the user to pick one of your three spell checkers (the unbalanced BST, the balanced BST, or the trie).
Represent a single stock in someones investment portfolio : Write a class StockHolding. The purpose of a StockHolding object is to represent a single stock in someone's investment portfolio.

Reviews

Write a Review

 

Computer Engineering Questions & Answers

  Implementing the technology architecture

You are proposing a new system that will link Rapid Cargo with all locations worldwide via a Web site that will also be used by customers to track deliveries.

  Assess the reliability of data gathered via paid internet

assess the reliability of data gathered via paid internet users. describe and assess the evaluation method being used

  Questionan ack scan does not provide in order about whether

questionan ack scan does not provide in order about whether a target machines ports are open or closed except rather

  Create a windows application that contains two textboxes

Create a Windows application that contains two textboxes and one button. Only allow positive integers to be used for the coordinates.

  What is the largest data set that you have processed

What is your definition of big data? What is the largest data set that you have processed? What did you do, and what were the results?

  Write a program that prompt the user to enter the x-position

Write a program that prompts the user to enter the x- and y-positions of a center point and a radius, using text fields.When the user clicks a Draw button.

  Implement a method for finding such a prime

Implement a method for finding such a prime by using the sieve algorithm. In this algorithm, we allocate a 2M cell Boolean array A.

  When are two vertices connected with an edge

Describe how you would model this situation using a directed graph, where paths in your graph should represent possible sequences of candy purchases.

  Explain most computer memories are composed of a large

Most computer memories are composed of a large number different devices that are interconnected to form the whole memory array which is accessed using the address bus.

  Develop an outline of the project plan for the testing

As part of the disaster recovery planning at a medium-sized business, you have been asked to develop a project plan to test the backups of production systems.

  Too much control is counter-productive define

"Too much control is counter-productive." Do you agree? Provide reasoning of the view.

  Which of the following return an array

CSS vendor prefixes are a way for browser companies to add support for experimental features before those features become part of the CSS specification.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd