Browse Source

little further along

Katrice Williams-Dredden 6 years ago
parent
commit
53fabeaac7
4 changed files with 72 additions and 11 deletions
  1. 7
    0
      pom.xml
  2. 11
    11
      src/main/java/Bins.java
  3. 19
    0
      src/main/java/Dice.java
  4. 35
    0
      src/main/java/DiceTest.java

+ 7
- 0
pom.xml View File

@@ -7,6 +7,13 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>Dicey-Lab</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>org.junit.jupiter</groupId>
13
+            <artifactId>junit-jupiter-api</artifactId>
14
+            <version>RELEASE</version>
15
+        </dependency>
16
+    </dependencies>
10 17
 
11 18
 
12 19
 </project>

+ 11
- 11
src/main/java/Bins.java View File

@@ -2,15 +2,15 @@
2 2
 public class Bins {
3 3
 
4 4
 
5
-    private int startingBound;
6
-    private int endingBound;
7
-
8
-    private int[] rollSums;
9
-
10
-
11
-
12
-
13
-    public Bins(int startingBound, int endingBound) {
14
-        sumOfRolls = new int[endingBound+1];
15
-    }
5
+//    private int startingBound;
6
+//    private int endingBound;
7
+//
8
+//    private int[] rollSums;
9
+//
10
+//
11
+//
12
+//
13
+//    public Bins(int startingBound, int endingBound) {
14
+//        sumOfRolls = new int[endingBound+1];
15
+//    }
16 16
 }

+ 19
- 0
src/main/java/Dice.java View File

@@ -1,6 +1,25 @@
1
+import java.util.Random;
2
+
1 3
 public class Dice {
4
+    public Integer numberOfDice;
5
+    public Integer dice;
2 6
 
7
+    //constructor, to refer to the #ofD has to use this.
3 8
     public Dice(Integer numberOfDice){
4 9
         this.numberOfDice = numberOfDice;
5 10
     }
11
+
12
+    public Integer sumOfToss(){
13
+        Random random = new Random();
14
+
15
+        Integer sumOfRoll = 0;
16
+        for(Integer i =0; i<numberOfDice; i++){
17
+            sumOfRoll += random.nextInt(6)+1;
18
+
19
+        }
20
+
21
+        return dice;
22
+    }
23
+
24
+
6 25
 }

+ 35
- 0
src/main/java/DiceTest.java View File

@@ -0,0 +1,35 @@
1
+
2
+
3
+import org.junit.jupiter.api.Test;
4
+import sun.jvm.hotspot.utilities.Assert;
5
+import org.junit.Assert;
6
+
7
+
8
+
9
+
10
+public class DiceTest {
11
+
12
+    @Test
13
+    public void testConstructorWithNumberOfDice(){
14
+        //Given
15
+        Integer expected = 11;
16
+        //When
17
+        Dice dice = new Dice(11);
18
+        Integer actual = dice.numberOfDice;
19
+        //Actual
20
+
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void testSumOfToss1(){
26
+        //Given
27
+        Dice dice = new Dice(2);
28
+
29
+        Integer actualToss = dice.sumOfToss();
30
+
31
+        Assert.
32
+//                (actualToss >= dice.numberOfDice && actualToss <= dice.numberOfDice * 6);
33
+    }
34
+
35
+}