import cse1030.Die; import java.util.List; import java.util.ArrayList; public class Lab01A { public static void main(String[] args) { Die d = new Die(); // Create a list to keep count of the number of times each // face value appears; initialize the counts to zero. List freq = new ArrayList(); for (int i = 0; i < d.getFaces(); i++) { freq.add(0); } final int TRIALS = 6000; for (int trial = 0; trial < TRIALS; trial++) { d.roll(); int value = d.getValue(); // The face values start at 1 but the list indices start // at 0 so we have to subtract one from value to get the // correct index. int frequencyOfValue = freq.get(value - 1); freq.set(value - 1, frequencyOfValue + 1); } int value = 1; for (Integer i : freq) { System.out.println(value + " : " + i); value++; } } }