Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class ScoreBoard { //number of games private int gameCount; //player records - you MUST use this for credit! //Do NOT change the name or

public class ScoreBoard { //number of games private int gameCount; //player records - you MUST use this for credit! //Do NOT change the name or type //NOTE: you cannot use any arrays or JCF instances in your implementation. private ThreeTenDynArray records; // ADD MORE PRIVATE MEMBERS HERE IF NEEDED! public ScoreBoard(int gameCount){ //Constructor // set the game count and initialize the records to be an empty list // - Throw IllegalArgumentException if gameCount is not positive // - Use this _exact_ error message for the exception // (quotes are not part of the message): // "Must have at least one game!" } public int playerCount(){ //report number of players //O(1)

return -1; //default return, remove or update as needed

} public int gameCount(){ //report number of games //O(1)

return -1; //default return, remove or update as needed }

public void addPlayer(PlayerRec player){ // append new player into record // if player is already present, updated the record // - assume each player has a unique name, i.e. matching names means same player // O(N) where N is the number of players present } public PlayerRec getPlayer(int index){ //return player record corresponding to index //return null for invalid indexes //O(1) return null; //default return, remove or update as needed }

public PlayerRec findPlayer(String name){ //find and return player record with the matching name //return null if not present // O(N) where N is the number of players present return null; //default return, remove or update as needed }

public boolean removePlayer(String name){ //remove player with the matching name //return true if a record is removed successfully; false otherwise // O(N) where N is the number of players present return false; //default return, remove or update as needed } public boolean changeScore(String name, int game, int newScore){ //set the score of the given game for the player with a matching name //return false if newScore cannot be set for any reason // (e.g player /game not present); return true otherwise // O(N) where N is the number of players present

return false; //default return, remove or update as needed } public int topTotalScore(){ //return largest total score among all players // return -1 if no player present // O(N) where N is the number of players present

return -3; //default return, remove or update as needed }

public ThreeTenDynArray topPlayers(){ //return the list of players (names only) with the top total score // if no player present, return an empty list // if there are multiple players, keep the names in the same order as // the players in the current record // O(N) where N is the number of players present // _if_ appending to the list to return is O(1) return null; //default return, remove or update as needed } public ThreeTenDynArray getGame(int game){ // return all scores for the given game index as a list // - if multiple players are present, keep scores in the same order as // order of players in records // - return an empty list if no players present or game index is invalid // O(M) where M is the number of players // _if_ appending to the list to return is O(1)

return null; //default return, remove or update as needed }

public int getGameTotal(int game){ // return the sum of all players' scores of the given game // - return -1 if no players present or game index is invalid // O(M) where M is the number of players return -10; //default return, remove or update as needed } public int getGameMax(int game){ // return the max score of the given game // - return -1 if no players present or game index is invalid // O(M) where M is the number of players return -10; //default return, remove or update as needed }

public int getGameMin(int game){ // return the min score of the given game // - return -1 if no players present or game index is invalid // O(M) where M is the number of players return -10; //default return, remove or update as needed

}

public boolean combine(ScoreBoard another, boolean append){ // add records from another scoreboard into the current one // - if a player is already present, update the record // - otherwise, // -if append is false, records from another should be added // to the start of the current records but keep their original order // -if append is true, add new records to the end of the list // Check main() below and description document for examples. // return false if two score boards cannot be combined (game count mismatch etc.); // return true otherwise // Although we do not have a big-O requirement for this method, you should // practice code reuse and utilize existing operations as much as possible. return false; //default return, remove or update as needed }

//****************************************************** //******* BELOW THIS LINE IS PROVIDED code ******* //******* Do NOT edit code! ******* //******* Remember to add JavaDoc ******* //******************************************************

public String gameToString(int game){ if (game<0 || game>gameCount()-1) return ("Game index " + game + " invalid!"); StringBuilder s = new StringBuilder("Game [" + game + "]: "); s.append(" "+ getGame(game).toString()); s.append(" Game Total: "+ getGameTotal(game) + " "); s.append(" Game Max: "+ getGameMax(game) + " "); s.append(" Game Min: "+ getGameMin(game) + " "); return s.toString().trim(); } @Override public String toString(){ StringBuilder s = new StringBuilder("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "); s.append("Game Count: " + gameCount() + "\t"); s.append(" Player Count: " + playerCount() + " "); s.append("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "); for (int i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

=+21.6. Prove (21.9) by Fubini's theorem.

Answered: 1 week ago