Posted by Lisa on Tuesday, October 13, 2009 at 12:37am.
I have to write program for a dice game and use a boolean variable in the application class of the dice game that equals true when snake eyes, doubles, and box cars have been meet. I am having a little trouble doing that in my application class so I was wondering if somebody can help me out. This is how my application class looks now:
package classes;
public class DiceGameApp {
public static void main (String [] args) {
DiceGame dice = new DiceGame ();
for (int rollCount = 0; rollCount < 10; rollCount ++) {
dice.roll();
System.out.println("\nYou rolled a " + dice.getDieone()+ " for dice one and a " +dice.getDietwo()+ " for dice two.");
if(dice.getDieone()== 1 && dice.getDietwo()== 1){
System.out.println ("\nYou have rolled snake eyes.");
}
else
{
if (dice.getDieone()== 6 && dice.getDietwo()== 6)
System.out.println("\nYou have rolled boxcars.");
else
System.out.println("\nYou have rolled doubles.");
}
}
}
}

Computer Science Java  jim, Tuesday, October 13, 2009 at 7:18am
A Boolean variable is a variable, like an int or a string, but whose value is either "true" or "false".
Try this little lump of code, and vary d1 and d2 values, to see the effect:
int d1 = 1
int d2 = 1
boolean snakeeyes;
boolean doubles;
boolean boxcars;
snakeeyes = (d1 + d2 == 2);
doubles = (d1 == d2);
boxcars = (d1 + d2 = 12);
System.out.println("Is this snakeeyes?");
System.out.println(snakeeyes);
// and you can also use it in a logical statement
System.out.println("Is this bpxcars?");
if (boxcars) System.out.println("Yes");
and so on.
It's not clear from your description whether your project calls for one boolean condition for each condition or one for any of them, but I hope this example will illustrate the general method.
Answer This Question
Related Questions
 Programming Logic  I need to create a flowchart/psuedocode for a dice game that...
 English  Playing the dice game, have a conversation about what you must do and ...
 Prob  A game is played using three 6sided dice. You throw these dice one time ...
 Mathematics for Liberal Arts  You are on a TV show. You have been asked to ...
 English expression  Playing the dice game, write down suitable responses and ...
 Algebra  You are a contestant on a game show and have the chance to win a car ...
 Math  At this year's State Fair, there was a dice rolling game. If you rolled ...
 English  Roll the dice. If you get 3 on the face of the dice, move forward for ...
 English expression  There is only one die in playing the dice game. They are ...
 Help me please Maths  Calvin is playing a game of Dungeons and Dragons. In ...
More Related Questions