ITEC 120 LAB 16 Back to Lab index page

Rolling Dice

Write a driver which will instantiate and roll four die objects. Use the die class: Die.java.

Print each roll, along with which roll it is.

Roll the dice until all 4 dice are the same, and count how many rolls that took and report it at the end. (Note: It will usually take many more than 8 rolls for the dice to be the same.)


Sample run:

Program displays:

Roll 1:     3       4       4       4
Roll 2:     2       1       6       5
Roll 3:     3       2       4       1
Roll 4:     5       3       5       4
Roll 5:     6       6       1       6
Roll 6:     3       2       4       2
Roll 7:     1       4       3       4
Roll 8:     3       3       3       3

It took 8 rolls for the dice to be the same!