Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trying to write a java program. I have some variables defined and think I'll need a random number generator to select who would go first

Trying to write a java program. I have some variables defined and think I'll need a random number generator to select who would go first but don't how to write the body of this.

I need to write a program that will simulate the penny drop game , where a top of a box has six marked slots and the #6 slot is slightly larger. For 2 or more players, each player gets 12 Pennies. The object of the game is to be the first to get rid of all your pennies. Here are the rules:

1. Determine who goes first by each player rolling the single dice cube. Highest # goes first; then play proceeds in a clockwise direction.

2. Player rolls the die and must put a penny in the game board slot corresponding to the number shown on the die.

3. If the player rolls a number that already has a penny in it, they must take all of the pennies showing on the board and then the turn goes to the next player.

4. A player must take at least one roll, but can take as many rolls as they want until they get stuck as in rule #3.

5. Hole number 6 lets the penny go inside the box so you can roll as many as 6s as possible without penalty

6. Play continues until a player runs out of pennies and is declared the winner.

The pennies are redistributed to start the next game. Now implement the Penny Drop game and be the first to get rid of all your pennies! Your version of the game will ask user to enter how many players to start the game (minimum two players and maximum six players) and they take turns to roll dice. During each players turn, after the player rolls the dice, your program should display the number of the current player, the number on the top of the dice, the current situation on the board (which slot has a penny, which slot is empty, how many pennies go through the box, and number of pennies each player has in hand. For example: Play # 2s turn to roll the dice and the number is: 4

S1 S2 S3 S4 S5 S6

|__0__ |__1__|__1__|__1__|__0__|__0__|

|_______________5________________|

Play # 1: 5 pennies

Play # 2: 3 pennies

Play # 3: 1 pennies 2

After a player rolls the dice for the first time, your program will also ask the user to choose continue to roll or pass it to the next player. If a player chooses to pass it to the next player, the next player will repeat the same process. At the end of the game, your program will declare the winner number and list the pennies in each players hand in ascending order. For example Play # 3: 0 pennies (Winner!) Play # 1: 2 pennies Play # 2: 8 pennies If a user wants to start a new game, start from all over again.

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions