Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First, you will need to create a “Player” class. This class will contain a field

ID: 3581285 • Letter: F

Question

First, you will need to create a “Player” class. This class will contain a field that will hold the player’s name, a field that tracks the player’s number of wins (correct guesses), a field that tracks the number of incorrect guesses, and have methods to get, set, and construct the object appropriately.

Your game’s underlying structure will rely on a circular linked-list. You can build your own Node class or use one of those provided by the book.

You can perform the game logic in your main method or you can abstract some or all tasks behind a GuessingGame class. The choice is yours.

How does the game work?

Prompt the user for the number of players that want to play your game.

Prompt each player to enter their name. Create a new Player object for each player, add it to a Node, and then link it into the list.

Once all of the players are added choose a random number between 1 and 100 and start playing. Each player gets 1 guess and then the next player gets a turn. The player that guesses the number wins. The players continuing taking turns in a “circular” fashion until one of them wins. Pay special attention to this interaction.

For each turn a player can guess a number, a player can choose to leave the game and be removed from the linked-list, or a player can choose to skip their turn and allow a new player to join in the game and be added to the linked-list. You’ll need a small menu system to handle this interaction. If there is only 1 player left in the list, that player is the winner.

Once a player is declared the winner, prompt them if they’d like to play again. If so, immediately start the next game with the existing players. The player that won the previous game will now go first. If they choose to not play again then show the statistics for each player during the run of games just played (total games played, wins, losses, etc.) and then exit the program.

Explanation / Answer

Player.java

LinkedList.java

Node.java