Roller.java
1    package chanceapps;
2    //This program uses the Die class.
3    import chance.Die;
4    
5    public class Roller {
6        public static void main(String[] args) {
7            // CREATE A STANDARD DIE AND ROLL IT 5 TIMES.
8            createAndRollStandardDieFiveTimes();
9    
10           // CREATE A TWENTY SIDED DIE AND ROLL IT 5 TIMES
11           createAndRollTwentySidedDieFiveTimes();
12   
13           // CREATE A STANDARD DIE AND ROLL IT 20 TIMES
14           createAndRollStandardDieTwentyTimes(20);
15   
16           // CREATE A STANDARD DIE AND ROLL IT 30 TIMES
17           createAndRollStandardDieThirtyTimes(30);
18   
19           //CREATE A NINE SIDED DIE AND ROLL IT 20 TIMES.
20           createAndRollNineSidedDieTwentyTimes(20);
21   
22           //CREATE A NINE SIDED DIE AND ROLL IT 30 TIMES
23           createAndRollNineSidedDieThirtyTimes(30);
24   
25   
26           //TEN TIMES, CREATE A STANDARD DIE AND ROLL IT TILL YOU GET A 1
27           //make ten rolls that roll till they get a one
28           System.out.println("\nTEN TIMES ROLE A STANDARD DIE UNTIL YOU GET A ONE.");
29           for (int i = 1; i <= 10; i++) {
30               createAndRollStandardDieFor1(i);
31           }
32           System.out.println("\nTEN TIMES ROLE A TWELVE SIDED DIE UNTIL YOU GET A ONE.");
33           for (int i = 1; i <= 10; i++) {
34               createAndRollTwelveSidedDieFor1(i);
35           }
36       }
37   
38       private static void createAndRollTwelveSidedDieFor1(int i) {
39           Die red = new Die(12);
40           System.out.println("\nDice RollSet Number " + i);
41           int help = 999;
42           while (help != 0) {
43               red.roll();
44               System.out.println("Roll was: " + red.top());
45               help = red.top() -1;
46           }
47       }
48   
49       private static void createAndRollStandardDieFor1(int i) {
50           Die red = new Die(6);
51           System.out.println("\nDice RollSet Number " + i);
52           int help = 999;
53           while (help != 0) {
54               red.roll();
55               System.out.println("Roll was: " + red.top());
56               help = red.top() -1;
57           }
58       }
59   
60       private static void createAndRollNineSidedDieThirtyTimes(int i) {
61           System.out.println("\nThirty Rolls on Nine Sided Die...");
62           Die red = new Die(9);
63           int x = 1;
64           while (i > 0) {
65               red.roll();
66               System.out.println("Roll " + x + "= " + red.top());
67               i = i - 1;
68               x = x + 1;
69           }
70       }
71   
72       private static void createAndRollNineSidedDieTwentyTimes(int i) {
73           System.out.println("\nTwenty Rolls on Nine Sided Die...");
74           Die red = new Die(9);
75           int x = 1;
76           while (i > 0) {
77               red.roll();
78               System.out.println("Roll " + x + "= " + red.top());
79               i = i - 1;
80               x = x + 1;
81           }
82       }
83   
84       private static void createAndRollStandardDieThirtyTimes(int i) {
85           System.out.println("\nThirty Rolls on Standard Die...");
86           Die red = new Die(6);
87           int x = 1;
88           while (i > 0) {
89               red.roll();
90               System.out.println("Roll " + x + "= " + red.top());
91               i = i - 1;
92               x = x + 1;
93           }
94       }
95   
96       private static void createAndRollStandardDieTwentyTimes(int i) {
97           System.out.println("\nTwenty Rolls on Standard Die...");
98           Die red = new Die(6);
99           int x = 1;
100          while (i > 0) {
101              red.roll();
102              System.out.println("Roll " + x + "= " + red.top());
103              i = i - 1;
104              x = x + 1;
105          }
106      }
107  
108  
109      private static void createAndRollTwentySidedDieFiveTimes() {
110          System.out.println("\nRolls a 20 sided Die...");
111          Die red = new Die(20);
112          red.roll();
113          System.out.println("First Roll: " + red.top());
114          red.roll();
115          System.out.println("Second Roll: " + red.top());
116          red.roll();
117          System.out.println("Third Roll: " + red.top());
118          red.roll();
119          System.out.println("Fourth Roll: " + red.top());
120          red.roll();
121          System.out.println("Fifth Roll: " + red.top());
122      }
123  
124      private static void createAndRollStandardDieFiveTimes() {
125          System.out.println("Rolls with Standard Die...");
126          Die red = new Die(6);
127          red.roll();
128          System.out.println("First Roll: " + red.top());
129          red.roll();
130          System.out.println("Second Roll: " + red.top());
131          red.roll();
132          System.out.println("Third Roll: " + red.top());
133          red.roll();
134          System.out.println("Fourth Roll: " + red.top());
135          red.roll();
136          System.out.println("Fifth Roll: " + red.top());
137      }
138  }
139