Bladeren bron

Added to bins Class

Trinh Tong 5 jaren geleden
bovenliggende
commit
75811b859a
3 gewijzigde bestanden met toevoegingen van 49 en 1 verwijderingen
  1. 20
    0
      src/main/java/Bins.java
  2. 0
    1
      src/main/java/Dice.java
  3. 29
    0
      src/test/java/BinsTest.java

+ 20
- 0
src/main/java/Bins.java Bestand weergeven

@@ -1,4 +1,24 @@
1
+import java.util.HashMap;
1 2
 
2 3
 public class Bins {
4
+    private HashMap<Integer, Integer> results;
5
+    int min = 0;
6
+    int max = 0;
7
+    // creates an array of required length
8
+    // increments the array @ index roll properly
3 9
 
10
+    public Bins(int min, int max) {
11
+        this.min = min;
12
+        this.max = max;
13
+
14
+        this.results = new HashMap<Integer, Integer>();
15
+
16
+        for (int i = min; i <= max; i++) {
17
+            this.results.put(i, 0);
18
+        }
19
+    }
20
+
21
+    public HashMap getHashMap() {
22
+        return this.results;
23
+    }
4 24
 }

+ 0
- 1
src/main/java/Dice.java Bestand weergeven

@@ -22,7 +22,6 @@ public class Dice {
22 22
         }
23 23
 
24 24
         return result;
25
-
26 25
     }
27 26
 
28 27
 }

+ 29
- 0
src/test/java/BinsTest.java Bestand weergeven

@@ -1,2 +1,31 @@
1
+import org.junit.Test;
2
+
1 3
 public class BinsTest {
4
+
5
+    Dice testDice;
6
+    Bins testBins;
7
+
8
+
9
+    /**
10
+     * test to make?
11
+     * get bin # { how many in that bin? }
12
+     *
13
+     */
14
+    public BinsTest() {
15
+
16
+        testDice = new Dice(2);
17
+        testBins = new Bins(2, 12);
18
+
19
+    }
20
+
21
+
22
+    @Test
23
+    public void testHashMap() {
24
+
25
+        for (int key: testBins.results.keySet()) {
26
+
27
+        }
28
+
29
+
30
+    }
2 31
 }