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

  Discuss the different kinds of storage devices

Discuss the different kinds of storage devices that you have used or that are available in the market.

  Has the use of technology made it easier or harder

Has the use of technology made it easier or harder for you to find work? Provide examples. Name at least three fields that technology has decreased the number.

  Write a program that asks the user to enter a month

Write a program that asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month.

  How would you convince users that letting the computer os

How would you convince users that letting the computer operating system or browser application remember their passwords is against good security practices?

  What security considerations are involved

Since I recommend a cloud-based network Verbania would need a cloud-based security software and a security software for their office computers.

  Describe how to configure file permissions

Preparation: This assignment provides you with the opportunity to discuss file management. File management is the means of creating, editing, updating.

  Explain the bellman-ford and dijkstra algorithms

Find the shortest path tree from every node to node 1 for the graph of Fig. using the Bellman-Ford and Dijkstra algorithms.

  Create an array that holds random integers

Create an array that holds 1000 random integers between 1 - 1000. Allow the user to enter an integer to search.

  Compute the average speed and mips rating

An application uses the following ASC instruction mix: ADD (20%), SHR (15%), LDA* (20%), STA (15%), TDX (15%), and LDX (15%).

  Calculate new cost of the item with the sales tax

Display the original item price and sales tax amount onto the screen. Calculate new cost of the item with the sales tax.

  What technologies would be necessary to facilitate plan

Explain how electronic document management is or could be used in your Information Systems class to eliminate all paper flow between the students and professor.

  What would be the new power level in milliwatts

What would be the new power level in milliwatts and dBms if you double the power four times. How does this impact the network?

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