Amy Gill 6 vuotta sitten
vanhempi
commit
0ba3b812e5
2 muutettua tiedostoa jossa 9 lisäystä ja 5 poistoa
  1. 6
    2
      src/main/java/Bins.java
  2. 3
    3
      src/main/java/Dice.java

+ 6
- 2
src/main/java/Bins.java Näytä tiedosto

@@ -2,9 +2,13 @@ import java.util.HashMap;
2 2
 
3 3
 public class Bins {
4 4
 
5
-    protected HashMap<Integer, Integer> numOfTimesWeveRolledEachNUm;
5
+    protected HashMap<Integer, Integer> numOfTimesWeveRolledEachNUm = new HashMap<Integer, Integer>();
6 6
 
7
-    public Bins(Integer minDiceRange, Integer maxDiceRange)
7
+    public Bins(Integer smallestPossible, Integer largestPossible){
8
+        for (Integer key = smallestPossible; key <= largestPossible; key++){
9
+            numOfTimesWeveRolledEachNUm.put(key, 0);
10
+        }
11
+    }
8 12
 
9 13
     public Bins(int start, int end) {
10 14
 

+ 3
- 3
src/main/java/Dice.java Näytä tiedosto

@@ -34,14 +34,14 @@ public class Dice {
34 34
     }
35 35
 
36 36
     public static void main(String[] args) {
37
-        Dice dice = new Dice(1); // for craps
37
+        Dice dice = new Dice(2); // for craps
38 38
         Dice dice2 = new Dice(5); // for yatzee
39 39
 
40 40
         Integer toss = dice.tossAndSum();
41 41
         Integer toss2 = dice2.tossAndSum();
42 42
 
43
-        System.out.println("The ressult of the first toss was " + toss);
44
-        System.out.println("The result of the second toss waS " + toss2);
43
+        System.out.println("The result of the first toss was " + toss);
44
+        System.out.println("The result of the second toss was " + toss2);
45 45
 
46 46
 
47 47