Connecting Tech Pros Worldwide Forums | Help | Site Map

Creating a simple Craps game in Java

Newbie
 
Join Date: Jun 2007
Posts: 1
#1: Jun 26 '07
Can you guys help me out? I'm trying to create a very simple game of craps but having some trouble. Below are the rules and requirements. Much appreciated!


Given the following rules for the game of Craps, simulate the play of a game, using the console to output the results of each roll and a WIN/LOSE message. Example output for a couple of runs is shown.

The player rolls two 6-sided dice (hint: use 1 + (int)(Math.random() * 6) ) to generate a random number between 1 and 6
A roll of 7 or 11 on the first try is a WIN
A roll of 2, 3 or 12 on the first try is a LOSE
Any other roll on the first try becomes the player's POINT
If a player rolled POINT, the player continues to roll until one of two things happens:
If a player in POINT rolls the POINT again, it is a WIN
If a player in POINT rolls 7, it is a LOSE
Example runs:
You rolled 7.
You win!

You rolled 12.
You lose!

You rolled 4. POINT is 4.
You rolled 3. POINT is 4.
You rolled 11. POINT is 4.
You rolled 4.
You win!

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Jun 26 '07

re: Creating a simple Craps game in Java


Quote:

Originally Posted by mer000

Can you guys help me out? I'm trying to create a very simple game of craps but having some trouble. Below are the rules and requirements. Much appreciated!


Given the following rules for the game of Craps, simulate the play of a game, using the console to output the results of each roll and a WIN/LOSE message. Example output for a couple of runs is shown.

The player rolls two 6-sided dice (hint: use 1 + (int)(Math.random() * 6) ) to generate a random number between 1 and 6
A roll of 7 or 11 on the first try is a WIN
A roll of 2, 3 or 12 on the first try is a LOSE
Any other roll on the first try becomes the player's POINT
If a player rolled POINT, the player continues to roll until one of two things happens:
If a player in POINT rolls the POINT again, it is a WIN
If a player in POINT rolls 7, it is a LOSE
Example runs:
You rolled 7.
You win!

You rolled 12.
You lose!

You rolled 4. POINT is 4.
You rolled 3. POINT is 4.
You rolled 11. POINT is 4.
You rolled 4.
You win!

What do you have so far?
First list down the objects/methods that you are going to need.
nomad's Avatar
Expert
 
Join Date: Mar 2007
Location: CA.
Posts: 570
#3: Jun 26 '07

re: Creating a simple Craps game in Java


Quote:

Originally Posted by mer000

Can you guys help me out? I'm trying to create a very simple game of craps but having some trouble. Below are the rules and requirements. Much appreciated!


Given the following rules for the game of Craps, simulate the play of a game, using the console to output the results of each roll and a WIN/LOSE message. Example output for a couple of runs is shown.

The player rolls two 6-sided dice (hint: use 1 + (int)(Math.random() * 6) ) to generate a random number between 1 and 6
A roll of 7 or 11 on the first try is a WIN
A roll of 2, 3 or 12 on the first try is a LOSE
Any other roll on the first try becomes the player's POINT
If a player rolled POINT, the player continues to roll until one of two things happens:
If a player in POINT rolls the POINT again, it is a WIN
If a player in POINT rolls 7, it is a LOSE
Example runs:
You rolled 7.
You win!

You rolled 12.
You lose!

You rolled 4. POINT is 4.
You rolled 3. POINT is 4.
You rolled 11. POINT is 4.
You rolled 4.
You win!

how many object do you need? Dice
write a ramdom method.
what kind of statement do you want to use.
if
for...

nomad
Reply