
/*
   This program rolls a pair of dice over and over until the dice
   come up sevens.  It counts and reports the number of rolls it
   takes before sevens come up.
*/

public class RollForSeven {

   public static void main(String[] args) {

      PairOfDice dice;  // The dice that we will roll.
      int rollCount;    // The number of times the dice have been rolled.
      int roll;         // The total of the two dice when they are rolled.

      dice = new PairOfDice();  // Create the pair of dice.

      rollCount = 0;  // Start counting at zero rolls.

      System.out.println("\nRolling for a seven...\n");

      do {
         roll = dice.roll();
         rollCount++;
         System.out.println("The dice came up " +
                                  dice.getDie1() + " and " +
                                  dice.getDie2() + ", for a total of " + roll);
      } while (roll != 7);

      // At this point, we know that the roll was 7, and rollCount is the
      // number of times the dice were rolled.

      System.out.println("\nIt took " + rollCount + " rolls to get a seven.\n");

   }

}
