Pārlūkot izejas kodu

Simulation is rolling Die

Akeem Cherry 6 gadus atpakaļ
vecāks
revīzija
fecf624b34
4 mainītis faili ar 108 papildinājumiem un 0 dzēšanām
  1. 8
    0
      pom.xml
  2. 56
    0
      src/main/java/Bins.java
  3. 22
    0
      src/main/java/Dice.java
  4. 22
    0
      src/main/java/Simulation.java

+ 8
- 0
pom.xml Parādīt failu

@@ -7,6 +7,14 @@
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>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+            <scope>compile</scope>
16
+        </dependency>
17
+    </dependencies>
10 18
 
11 19
 
12 20
 </project>

+ 56
- 0
src/main/java/Bins.java Parādīt failu

@@ -1,4 +1,60 @@
1
+import org.junit.Test;
1 2
 
2 3
 public class Bins {
3 4
 
5
+    Bins(int min, int max) {
6
+
7
+
8
+        Bins results = new Bins(2, 12);
9
+        Integer numberOfTwo = results.getBin(2);
10
+        results.incrementBin(2);
11
+
12
+        new Bins(2, 12);
13
+        Integer numberOfThree = results.getBin(3);
14
+        results.incrementBin(3);
15
+
16
+        new Bins(2, 12);
17
+        Integer numberOfFour = results.getBin(4);
18
+        results.incrementBin(4);
19
+
20
+        new Bins(2, 12);
21
+        Integer numberOfFive = results.getBin(5);
22
+        results.incrementBin(5);
23
+
24
+        new Bins(2, 12);
25
+        Integer numberOfSix = results.getBin(6);
26
+        results.incrementBin(6);
27
+
28
+        new Bins(2, 12);
29
+        Integer numberOfSeven = results.getBin(7);
30
+        results.incrementBin(7);
31
+
32
+        new Bins(2, 12);
33
+        Integer numberOfEight = results.getBin(8);
34
+        results.incrementBin(8);
35
+
36
+        new Bins(2, 12);
37
+        Integer numberOfNine = results.getBin(9);
38
+        results.incrementBin(9);
39
+
40
+        new Bins(2, 12);
41
+        Integer numberOfTen = results.getBin(10);
42
+        results.incrementBin(10);
43
+
44
+        new Bins(2, 12);
45
+        Integer numberOfEleven = results.getBin(11);
46
+        results.incrementBin(11);
47
+
48
+        new Bins(2, 12);
49
+        Integer numberOfTvelve = results.getBin(12);
50
+        results.incrementBin(12);
51
+    }
52
+
53
+    private Integer getBin(int i) {
54
+        return null;
55
+    }
56
+
57
+    private void incrementBin(int i) {
58
+    }
59
+
4 60
 }

+ 22
- 0
src/main/java/Dice.java Parādīt failu

@@ -1,4 +1,26 @@
1 1
 public class Dice {
2 2
 
3
+    private int die1;
4
+    private int die2;
3 5
 
6
+    public Dice() {
7
+        roll();
8
+    }
9
+
10
+    public void roll() {
11
+        die1 = (int) (Math.random()*6) + 1;
12
+        die2 = (int) (Math.random()*6) + 1;
13
+    }
14
+
15
+    int getDie1() {
16
+        return die1;
17
+    }
18
+
19
+    int getDie2() {
20
+        return die2;
21
+    }
22
+
23
+    int getTotal() {
24
+        return die1 + die2;
25
+    }
4 26
 }

+ 22
- 0
src/main/java/Simulation.java Parādīt failu

@@ -1,5 +1,27 @@
1 1
 public class Simulation {
2 2
 
3 3
 
4
+    public Simulation(int i, int i1) {
5
+
6
+    }
7
+
8
+    public static void main(String[] args) {
9
+            Simulation sim = new Simulation(2, 10000);
10
+
11
+            Dice dice;
12
+            int rollCount;
13
+
14
+            dice = new Dice();
15
+            rollCount = 0;
16
+
17
+            for (int i = 1; i <= 10000; i++) {
18
+                dice.roll();
19
+                System.out.println("The roll total is " + dice.getTotal());
20
+                rollCount++;
21
+            }
22
+            System.out.println(sim);
23
+
24
+        }
25
+
4 26
 
5 27
 }