ソースを参照

added visual representtion of statistics per result

Jonathan Hinds 5 年 前
コミット
7259334a87
共有3 個のファイルを変更した21 個の追加2 個の削除を含む
  1. 11
    0
      src/main/java/JonathanHinds.md
  2. 1
    1
      src/main/java/Main.java
  3. 9
    1
      src/main/java/Simulation.java

+ 11
- 0
src/main/java/JonathanHinds.md ファイルの表示

@@ -0,0 +1,11 @@
1
+index of the array: 0 | value rolled : 2 | amount of times this value was rolled: 27480 | percent : 0.03 : ***
2
+index of the array: 1 | value rolled : 3 | amount of times this value was rolled: 55834 | percent : 0.06 : ******
3
+index of the array: 2 | value rolled : 4 | amount of times this value was rolled: 83283 | percent : 0.08 : ********
4
+index of the array: 3 | value rolled : 5 | amount of times this value was rolled: 111234 | percent : 0.11 : ***********
5
+index of the array: 4 | value rolled : 6 | amount of times this value was rolled: 138533 | percent : 0.14 : ***************
6
+index of the array: 5 | value rolled : 7 | amount of times this value was rolled: 166878 | percent : 0.17 : *****************
7
+index of the array: 6 | value rolled : 8 | amount of times this value was rolled: 138501 | percent : 0.14 : ***************
8
+index of the array: 7 | value rolled : 9 | amount of times this value was rolled: 110907 | percent : 0.11 : ***********
9
+index of the array: 8 | value rolled : 10 | amount of times this value was rolled: 83260 | percent : 0.08 : ********
10
+index of the array: 9 | value rolled : 11 | amount of times this value was rolled: 56227 | percent : 0.06 : ******
11
+index of the array: 10 | value rolled : 12 | amount of times this value was rolled: 27863 | percent : 0.03 : ***

+ 1
- 1
src/main/java/Main.java ファイルの表示

@@ -3,7 +3,7 @@ public class Main
3 3
     public static void main(String[] args)
4 4
     {
5 5
         //create a new simulation
6
-        Simulation sim = new Simulation(100, 6,100);
6
+        Simulation sim = new Simulation(2, 6,1000000);
7 7
 
8 8
         //run the new simulation
9 9
         sim.runSimulation();

+ 9
- 1
src/main/java/Simulation.java ファイルの表示

@@ -44,8 +44,16 @@ public class Simulation {
44 44
             int currentResult = this.bin.getResults()[i];
45 45
             //get the statistics
46 46
             double stats = ((double)currentResult/(double)this.rolls);
47
+            //round the statistic to two decimal places
47 48
             stats = round(stats, 2);
48
-            System.out.println("index of the array: " +i + " | value rolled : " + (i + this.dice.getAmount()) + " | amount of times this value was rolled: " + currentResult + " | percent : " + stats);
49
+            //create the string that will output the information
50
+            String result = "index of the array: " +i + " | value rolled : " + (i + this.dice.getAmount()) + " | amount of times this value was rolled: " + currentResult + " | percent : " + stats + " : ";
51
+            //conver the percentage to an integer
52
+
53
+            for(int m = 0; m < stats * 100.0; m ++){
54
+                result += "*";
55
+            }
56
+            System.out.println(result);
49 57
         }
50 58
     }
51 59
 }