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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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