Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package cubacuba; import java.util. * ; import java.util.concurrent.atomic.AtomicInteger; class Player { private final AtomicInteger playerIDCounter = new AtomicInteger ( 1 ) ; String playerID; String
package cubacuba;
import java.util.;
import java.util.concurrent.atomic.AtomicInteger;
class Player
private final AtomicInteger playerIDCounter new AtomicInteger;
String playerID;
String playerName;
int score;
String gameID;
Player next;
PlayerString playerName, String gameID
this.playerID generatePlayerID;
this.playerName playerName;
this.score ;
this.gameID gameID;
this.next null;
private String generatePlayerID
return P playerIDCounter.getAndIncrement;
public String getPlayerID
return playerID;
public void setPlayerNameString newName
this.playerName newName;
public void setScoreint newScore
this.score newScore;
public int getScore
return score;
public String getGameID
return gameID;
class Game
String gameID;
String gameName;
Player head;
GameString gameName
this.gameID generateGameIDgameName;
this.gameName gameName;
this.head null;
private String generateGameIDString gameName
return gameName.substringtoUpperCase;
public String getGameID
return gameID;
public void addPlayerPlayer player
player.next head;
head player;
public void removePlayerString playerID
if head null
return;
if headgetPlayerIDequalsplayerID
head head.next;
return;
Player current head;
Player previous null;
while current null && current.getPlayerIDequalsplayerID
previous current;
current current.next;
if current null
previous.next current.next;
public Player findPlayerString playerID
Player current head;
while current null && current.getPlayerIDequalsplayerID
current current.next;
return current;
public class GameScoreManagementSystem
static List games new ArrayList;
private static Scanner scanner new ScannerSystemin;
public static void mainString args
initializeGames;
char ch;
do
printMainMenu;
ch scanner.nexttoUpperCasecharAt;
switch ch
case :
displayStandingsMenu;
break;
case :
editPlayerDataMenu;
break;
case X:
System.out.println
Exiting Game Score Management System";
break;
default:
System.out.println
Invalid entry. Please select or X
;
while ch X;
private static void initializeGames
games.addnew GameBadminton;
games.addnew GameFootball;
games.addnew GameVolleyball;
private static void printMainMenu
System.out.println
Game Score Management System;
System.out.println Display Standings";
System.out.println Edit Player Data";
System.out.printlnX Exit";
System.out.printEnter your choice: ;
private static void displayStandingsMenu
if gamesisEmpty
System.out.println
No games available. Please add games first.";
return;
System.out.println
Display Standings Menu;
for int i ; i games.size; i
System.out.printlni games.getigameName;
System.out.printlnX Back to Main Menu";
System.out.printEnter your choice: ;
char gameChoice scanner.nexttoUpperCasecharAt;
if gameChoice X
System.out.println
Returning to Main Menu";
else if gameChoice && gameChoice
int gameIndex Character.getNumericValuegameChoice;
if gameIndex && gameIndex games.size
displayGameStandingsgamesgetgameIndex;
else
System.out.println
Invalid entry. Please select a valid game or X
;
else
System.out.println
Invalid entry. Please select a valid game or X
;
private static void displayGameStandingsGame game
if gamehead null
System.out.println
The player list for game.gameName is empty.
;
return;
Player current game.head;
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