Kaynağa Gözat

Merge 7fa69cbf0c9e1ae47da040f4469348f841f4ebe0 into 1eaff706f0dcc7a467d1c6648bcb494e313ba6a5

SupaGrammer 6 yıl önce
ebeveyn
işleme
883e879307
No account linked to committer's email

+ 42
- 1
src/main/java/Dice.java Dosyayı Görüntüle

@@ -1,4 +1,45 @@
1
+
2
+import java.util.Random;
3
+
1 4
 public class Dice {
5
+//declare variables
6
+    public int diceCount;
7
+    public int tossMax;
8
+    public int tossMin;
9
+//declare number of dice
10
+    public Dice() {
11
+        this(1);
12
+    }
13
+//get number of dice used
14
+    public Dice(int numOfDice) {
15
+        this.diceCount = numOfDice;
16
+        this.tossMax = this.diceCount * 6;
17
+        this.tossMin = this.diceCount;
18
+    }
19
+//getters for maximum and minimum number of tosses
20
+    public int getTossMax() {
21
+        return tossMax;
22
+    }
23
+
24
+    public int getTossMin() {
25
+        return tossMin;
26
+    }
2 27
 
28
+    public int sumOfToss() {
29
+        int sum = 0;
30
+        for (int i = 0; i < diceCount; i++) {
31
+            sum += (int)(Math.random() * 6) + 1;
32
+        }
33
+        return sum;
34
+    }
3 35
 
4
-}
36
+    public static void main(String[] args) {
37
+//instance of number of dice used for each game
38
+        Dice game1 = new Dice(2);
39
+        Dice game2 = new Dice(5);
40
+        Integer tossForGame1 = game1.sumOfToss();
41
+        Integer tossForGame2 = game2.sumOfToss();
42
+        System.out.println(tossForGame1);
43
+        System.out.println(tossForGame2);
44
+    }
45
+}

+ 4
- 0
src/main/javaTest/BinsTest.java Dosyayı Görüntüle

@@ -0,0 +1,4 @@
1
+package PACKAGE_NAME;
2
+
3
+public class BinsTest {
4
+}

+ 4
- 0
src/main/javaTest/DiceTest.java Dosyayı Görüntüle

@@ -0,0 +1,4 @@
1
+package PACKAGE_NAME;
2
+
3
+public class DiceTest {
4
+}

+ 4
- 0
src/main/javaTest/SimulationTest.java Dosyayı Görüntüle

@@ -0,0 +1,4 @@
1
+package PACKAGE_NAME;
2
+
3
+public class SimulationTest {
4
+}