Browse Source

Dice class and Test

Jose Bedolla 6 years ago
parent
commit
794dc108b9

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


+ 8
- 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
-    private int sides;
4
+
5
     private int value;
5
     private int value;
6
 
6
 
7
-    public void Roll(){
7
+    public void roll(){
8
+
9
+        value = (int) (Math.random()*6+1);
8
 
10
 
9
     }
11
     }
12
+    public int getValue()
13
+    {
14
+        return value;
15
+    }
10
 }
16
 }

+ 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
+}