diff --git a/binResults.txt b/binResults.txt
new file mode 100644
index 0000000..6fa682c
--- /dev/null
+++ b/binResults.txt
@@ -0,0 +1,11 @@
+ 2 : 27769: 0.03 **
+ 3 : 55480: 0.06 *****
+ 4 : 83443: 0.08 ********
+ 5 : 111434: 0.11 ***********
+ 6 : 138721: 0.14 *************
+ 7 : 166952: 0.17 ****************
+ 8 : 139571: 0.14 *************
+ 9 : 110167: 0.11 ***********
+10 : 82916: 0.08 ********
+11 : 55762: 0.06 *****
+12 : 27785: 0.03 **
diff --git a/pom.xml b/pom.xml
index 7219542..3eae192 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,26 @@
com.zipcodewilmington
Dicey-Lab
1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 15
+ 15
+
+
+
+
+
+
+ junit
+ junit
+ 4.8.2
+ test
+
+
\ No newline at end of file
diff --git a/src/main/java/Bins.java b/src/main/java/Bins.java
index b9da83e..b4824ac 100644
--- a/src/main/java/Bins.java
+++ b/src/main/java/Bins.java
@@ -1,4 +1,28 @@
+import java.util.Arrays;
public class Bins {
+ int min;
+ int max;
+ Integer[] bins;
+
+ public Bins(int min, int max) {
+ this.min = min;
+ this.max = max;
+ bins = new Integer[max - min + 1];
+ Arrays.fill(bins, 0);
+ }
+
+ public int getBin(int binNumber) {
+ return bins[binNumber - min];
+ }
+
+ public int incrementBin(int binNumber) {
+ return bins[binNumber - min]++;
+ }
+
+ public Integer[] getBins() {
+ return bins;
+ }
}
+
diff --git a/src/main/java/Dice.java b/src/main/java/Dice.java
index 2283c96..b0ab35a 100644
--- a/src/main/java/Dice.java
+++ b/src/main/java/Dice.java
@@ -1,4 +1,25 @@
+import java.util.ArrayList;
+import java.util.Random;
+
public class Dice {
+ int numOfDice;
+
+ public Dice(int numOfDice) {
+ this.numOfDice = numOfDice;
+ }
+
+ public Dice() {}
+
+ public int getNumberOfDice() {
+ return numOfDice;
+ }
+ public int tossAndSum() {
+ int sum = 0;
+ for(int i = 0; i < numOfDice; i++) {
+ sum += (Math.random() * 6) + 1;
+ }
+ return sum;
+ }
}
diff --git a/src/main/java/Simulation.java b/src/main/java/Simulation.java
index 73d86e8..537ade2 100644
--- a/src/main/java/Simulation.java
+++ b/src/main/java/Simulation.java
@@ -1,5 +1,54 @@
+import java.util.ArrayList;
+import java.util.List;
+
public class Simulation {
+ int numOfDice;
+ int numOfRolls;
+ Dice dice;
+ Bins bins;
+
+ public Simulation(int numOfDice, int numOfRolls) {
+ this.numOfDice = numOfDice;
+ this.numOfRolls = numOfRolls;
+ }
+
+ public void runSimulation(){
+ int result;
+ this.bins = new Bins(numOfDice, numOfDice * 6);
+ this.dice = new Dice(numOfDice);
+ for(int i = 0; i < numOfRolls; i++) {
+ result = dice.tossAndSum();
+ bins.incrementBin(result);
+ }
+ System.out.println("");
+ }
+
+ public void printResults() {
+ for(int i = numOfDice; i <= numOfDice * 6; i++) {
+ Double percentage = (double) bins.getBin(i) / numOfRolls;
+ System.out.printf(
+ "%2d : %7d: %.2f ", i, bins.getBin(i), percentage);
+ for(int j = 1; j < percentage * 100; j++) {
+ System.out.print("*");
+ }
+ System.out.println();
+ }
+
+ }
+
+ public double getPercentage(int numOfRolls, Bins bins) {
+ double percentage = 0;
+ for(int element : bins.getBins()) {
+ percentage = ((double) element / numOfRolls);
+ }
+ return percentage;
+ }
+ public static void main(String[] args) {
+ Simulation simulation = new Simulation(2, 1000000);
+ simulation.runSimulation();
+ simulation.printResults();
+ }
}
diff --git a/src/test/java/BinsTest.java b/src/test/java/BinsTest.java
new file mode 100644
index 0000000..8916685
--- /dev/null
+++ b/src/test/java/BinsTest.java
@@ -0,0 +1,4 @@
+public class BinsTest {
+
+
+}
diff --git a/src/test/java/DiceTest.java b/src/test/java/DiceTest.java
new file mode 100644
index 0000000..63d4667
--- /dev/null
+++ b/src/test/java/DiceTest.java
@@ -0,0 +1,33 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DiceTest {
+
+ @Test
+ public void testGetNumberOfDice() {
+ //given
+ int expected = 2;
+ //when
+ Dice dice = new Dice(expected);
+ int actual = dice.getNumberOfDice();
+ //then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testTossAndSum() {
+ //given
+ int numOfDice = 2;
+ int expected = 8;
+ Dice dice = new Dice(2);
+ //when
+ int actual = dice.tossAndSum();
+ //then
+ System.out.println(actual);
+ }
+}
+
+
+// need number of dice
+// need to roll dice
+// need sum of dice