Browse Source

Merged Joses dice changes

Jonathan Hinds 6 years ago
parent
commit
fd7210b6ca

BIN
.DS_Store View File


BIN
src/.DS_Store View File


BIN
src/main/.DS_Store View File


BIN
src/main/java/.DS_Store View File


BIN
src/main/java/io/.DS_Store View File


BIN
src/main/java/io/zipcoder/.DS_Store View File


+ 5
- 2
src/main/java/io/zipcoder/casino/Dice.java View File

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 public class Dice {
3
 public class Dice {
4
+
5
+
4
     private int value;
6
     private int value;
5
 
7
 
6
     public void roll(){
8
     public void roll(){
7
 
9
 
8
-
10
+        value = (int) (Math.random()*6+1);
9
 
11
 
10
     }
12
     }
11
 
13
 
12
-    public int getValue() {
14
+    public int getValue()
15
+    {
13
         return value;
16
         return value;
14
     }
17
     }
15
 }
18
 }

+ 27
- 0
src/test/java/io/zipcoder/casino/DiceTest.java View File

1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class DiceTest {
7
+
8
+    @Test
9
+    public void getValueTest()
10
+    {
11
+        Dice dice = new Dice();
12
+        dice.roll();
13
+        int actual = dice.getValue();
14
+        boolean expected = true;
15
+        boolean x;
16
+        if (actual<=6 || actual>=1)
17
+        {
18
+            x = true;
19
+        }
20
+        else
21
+            {
22
+                x =false;
23
+            }
24
+
25
+        Assert.assertEquals(expected,x);
26
+    }
27
+}