Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need to complete question one the code above is example and how it should work public class Player { private String playerName; private int

image text in transcribed
image text in transcribed
image text in transcribed
i need to complete question one the code above is example and how it should work
public class Player { private String playerName; private int highScore; public Player (String name, int score) { playerName = name; highScore = score; /** @param score an int value representing the player's most recent score updates the value of highScore to score if this is higher than the cur rent value */ public void updateScore(int score) { if(score > highScore) highScore = score; /** @return the player's name */ public String getName() { return playerName; } /** @return the high score of the player */ public int getHighScore() { return highScore; } public class Scorelist { private ArrayList scoreboard; // listed in decreasing order of highScore value // no two Player objects have the same playerName /** Moves the Player object at index pos upwards in scoreboard to the cor rect * position in the list according to its highScore value * @param pos a valid index for the scoreboard list */ private void moveUp(int pos) { /* to be implemented in part (a) */ } /** Searches for a Player in scoreboard with a matching name and updates the high score if there is one. Otherwise a new player is created with the name and high score * passed at the end of scoreboard. The new/updated Player object is move d up to * the correct place on the list using the method movelp. * @param name the name of the player who recorded the score * @param score the score recorded * @return true if a new Player was created; false otherwise */ public boolean newScore(String name, int score) { /* to be implemented in part (b) */ } // There may be instance variables, constructors, and methods that are no t shown. } Question 1 3 pts Write the scoreList method moveUp that compares the highScore of the Player object at the index pos to each Player in the list above it. This object will be moved to the correct position in the list (you may assume that all items with an index smaller than pos in the list are in the correct order). Complete method highScore below. /** Moves the Player object at index pos upwards in scoreboa rd to the correct * position in the list according to its highScore value * @param pos a valid index for the scoreboard list */ private void moveUp(int pos)

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions