Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the class GameEntry, and ScoreBoard.The ScoreBoard saves the entries in an ascending order, so we have to shift the elements when we add or

image text in transcribed
Given the class GameEntry, and ScoreBoard.The ScoreBoard saves the entries in an ascending order, so we have to shift the elements when we add or remove an element. Assume we do not want to save the entries sorted in order to avoid shift operations, however the array in the board should not have null values between the elements. a) Rewrite the methods add(e), remove(i) without using any loops( so they have better performance). b) Add method highestScore): it returns the name of the entry with the heights score. If there are many, it returns the first occurrence of them. c) Add method removeMax) which removes the entry that has the maximum score. If there are many, it removes the first occurrence of them. d) Add method noDuplicate () which removes all duplicated scores. For example if there are three entries with score 50, two of them will be removed. e) To class GameEntry, add method toString that returns name and score of the entry, and to class ScoreBoard, add method print() that prints all entries currently in the board. 1) Create a test class call it BoardTest with main. Add five entries to the board, and print thenm Test each one of the methods above. (print the entries of the board when needed to show that the method works). You should submit: The java code of : class GameEntry, class ScoreBoard, and class BoardTest. private Seing ame / Attempt to add a new score to the collection (f it ia hgh mou) the new entry e eally a high scoe /**Class for storing highscores ianarrayinsondecreasingod"*/ // number of actual entries 1 2 public class Scoreboard I 3 private int numEntries 4 private GameEntryl ] board I/ aay of gane entries (names&scoe / Constructs an empty sconeboard with the given capacity for storing entries 6public Scoreboard int capaity) [ new G // more methods will go here 25 / Remove and returm the high score at index i 26 public GameEntry nemovel int i) throws IndexOutOBoundsException ( 28 29 Gamefntry temp = borat 30 for (intj=i;jcnabenes _ 1:j++) 3l board-board- 2 board numEntries-1]u 33 numEntries-2 34 return temp /save the object to be removed // null out the old last scoe / retum the removed object //conresom i (not doen) // move one cell to the left

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions