/* * CrapsLoop.java * * Created on March 11, 2003, 9:12 AM */ package dice; /** * * @author mike */ public class CrapsLoop { /** Creates a new instance of BabyCraps */ public CrapsLoop() { } /** * @param args the command line arguments */ public static void main(String[] args) { boolean done = false; // default to not done int point = 0; // create dice Die die1 = new Die(); Die die2 = new Die(); // roll dice int val1 = die1.getRoll(); int val2 = die2.getRoll(); // get total int total = val1 + val2; System.out.println("Rolled: " + die1 + " " + die2 + " = " + total); // determine if win, lose, or keep rolling switch (total) { case 7: case 11: System.out.println("You win!!!"); done = true; break; case 2: case 3: case 12: System.out.println("You lose :-("); done = true; break; default: point = total; System.out.println("We keep rolling"); } // roll until winner or loser while (!done) { // roll again val1 = die1.getRoll(); val2 = die2.getRoll(); // get total total = val1 + val2; System.out.println("Rolled: " + die1 + " " + die2 + " = " + total); // determine if win, lose or keep rolling if (total == 7) { System.out.println("You lose - 7 is bad here!"); done = true; } else if (total == point) { System.out.println("You win!!!!!!"); done = true; } else { System.out.println("We keep rolling"); } } // end while } }