Question
class Main { public static void main(String[] args) { // The main method Scoreboard scoresBoard = new Scoreboard(8); String[] names = { Rob, Mike, Rose,
class Main { public static void main(String[] args) { // The main method Scoreboard scoresBoard = new Scoreboard(8); String[] names = { "Rob", "Mike", "Rose", "Jill", "Jack", "Anna", "Paul", "Bob" }; int[] scores = { 750, 1105, 590, 510, 400, 740, 720, 660 }; for (int i = 0; i < names.length; i++) { GameEntry gE = new GameEntry(names[i], scores[i]); System.out.println("Adding " + gE); scoresBoard.add(gE); System.out.println(" Scoreboard: " + scoresBoard); } // Follow the requirements and add your implementation // Task1 code goes here: with public void add(GameEntry e), try two cases:
Task 1. Please follow the sample code of main() and write your own code to try the function public void add(GameEntry e) of class GameEntry.java.
Note: You should follow the existing code in main() and wirte your own code. In your code, you should create two GameEntryobjects, e1 and e2, and and add them to scoreBoard by invoking scoresBoard.add(). Make sure their "score" values satisfy two cases.
1) e1.getScore() <= board[numEntries-1].getScore().
2) e2.getScore() > board[numEntries-1].getScore().
Print all the elements of scroeBoard before and after adding e1/e2seperately. Draw the trace on a paper and explain the elements change.
Task 2. Write your own code and try function public GameEntry remove(int i) with the following cases:
1) i < 0;
2) i >= numEntries;
3) 0 <= i < numEntries
Print all the elements of scroeBoard after each time you invoke remove() function. Draw the trace on a paper and explain the elements change in each case.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started