/** * Write a description of class Driver here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; public class Driver { public static void main(String[ ] args) { Scanner keyboard = new Scanner(System.in); //for input Die d1 = new Die(); Die d2 = new Die(); int sum; int point; boolean again = true; do { //roll d1.roll(); d2.roll(); System.out.println("results of your first roll:"); System.out.println("Die 1: " + d1.toString()); System.out.println("Die 2: " + d2.toString()); sum = d1.getFace() + d2.getFace(); boolean done = false; System.out.println("the sum of your roll is " + sum); if ( sum == 7 || sum == 11 ) { System.out.println("you win!"); done = true; } else if ( sum == 2 || sum == 3 || sum == 12 ) { System.out.println("sorry, you lose"); done = true; } else if (done == false ) { do { point = sum; sum = 0; d1.roll(); d2.roll(); System.out.println("results of your next roll:"); System.out.println("Die 1: " + d1.toString()); System.out.println("Die 2: " + d2.toString()); sum += ( d1.getFace() + d2.getFace() ); if (point < sum) { System.out.println("BUST!"); done = true; } else if ( point == 7 ) { System.out.println("FAIL"); done = true; } else if ( point == sum) { System.out.println("You win!"); done = true; } } while (done == false ); } char repeat = 0; do { System.out.println("Game is over. play again? (y/n)"); repeat = keyboard.next().charAt(0); } while (repeat !='Y' || repeat != 'y' || repeat != 'N' || repeat !='n' ); if (repeat == 'Y' || repeat == 'y') again = true; else again = false; } while (again == true); } }