Browse Source

completed Dicy

Jevit Tith 6 years ago
parent
commit
7cf299213f
6 changed files with 27 additions and 0 deletions
  1. BIN
      .DS_Store
  2. BIN
      src/.DS_Store
  3. BIN
      src/main/.DS_Store
  4. 11
    0
      src/main/java/Bins.java
  5. 12
    0
      src/main/java/Dice.java
  6. 4
    0
      src/main/java/Simulation.java

BIN
.DS_Store View File


BIN
src/.DS_Store View File


BIN
src/main/.DS_Store View File


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

@@ -1,4 +1,15 @@
1
+import java.util.ArrayList;
1 2
 
2 3
 public class Bins {
3 4
 
5
+    public ArrayList<Integer> record = new ArrayList<Integer>();
6
+
7
+    public ArrayList<Integer> recordRoll (int numberOfRolls){
8
+
9
+        for (int i = 0; i < numberOfRolls; i++) {
10
+            record.add(Dice.roll(6));
11
+        }
12
+        return record;
13
+    }
14
+
4 15
 }

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

@@ -1,4 +1,16 @@
1
+import java.util.Random;
2
+
1 3
 public class Dice {
2 4
 
3 5
 
6
+    public static int roll (int numberOfSides){
7
+        numberOfSides = numberOfSides - 1;
8
+        int randomNumber;
9
+
10
+        randomNumber = ((int)Math.rint(Math.random()*numberOfSides)) + 1;
11
+
12
+        return randomNumber;
13
+    }
14
+
15
+
4 16
 }

+ 4
- 0
src/main/java/Simulation.java View File

@@ -1,5 +1,9 @@
1 1
 public class Simulation {
2 2
 
3
+    public static void main(String[] args) {
4
+        Bins collect = new Bins();
3 5
 
6
+        System.out.println(collect.recordRoll(15));
7
+    }
4 8
 
5 9
 }