Toss some dice, ONE Million times, and produce an ASCII graph.
De'Jon Johnson fdedd6f5af Completed 6 年之前
src Completed 6 年之前
.gitignore empty project 6 年之前
README.md Completed 6 年之前
pom.xml Completed 6 年之前

README.md

Kris-Tof Johnson.DeJon.Dice Toss

Create a Johnson.DeJon.Dice class that acts like a set of N random-tossed dies.

Johnson.DeJon.Dice dice = new Johnson.DeJon.Dice(2); // for craps
Johnson.DeJon.Dice dice = new Johnson.DeJon.Dice(5); // for yatzee

Integer toss = dice.tossAndSum();

make a couple unit tests for the Johnson.DeJon.Dice class.

Create a tracking class Johnson.DeJon.Bins that can be used to track the results of dice tosses.

Johnson.DeJon.Bins results = new Johnson.DeJon.Bins(2, 12); // for bins from 2..12
Integer numberOfTens = results.getBin(10); // returns the number of tens in the 10 bin
results.incrementBin(10); // should increment bin # 10

make a couple unit tests for the Johnson.DeJon.Bins class. Your test methods should follow this template:

in the tests
Create a new Bin
increment a bin some number of times in a for loop, say `max = 100;` times,
then get the Bin value,
compare the Bin value to `max`, they should be equal.

Create a Johnson.DeJon.Simulation class whose Constructor takes arguments:

numberOfDies to throw
numberOfTosses to run

Create a simulation where two dies are thrown one million times. Keep track of each roll by incrementing the correct Bin.

Johnson.DeJon.Simulation sim = new Johnson.DeJon.Simulation(2, 10000);

sim.runSimulation();

sim.printResults();

You can use a main() to run the simulations.

In your pull requests, create a new file with your unique name as the filename. Paul's would be PaulResults.md

Paste a copy of your text results into that file and then submit your pull request.

the results of the sim.printResults() should be an output string that looks like this:

***
Johnson.DeJon.Simulation of 2 dice tossed for 1000000 times.
***

 2 :    27917: 0.03 **
 3 :    55422: 0.06 *****
 4 :    83457: 0.08 ********
 5 :   110961: 0.11 ***********
 6 :   139098: 0.14 *************
 7 :   166977: 0.17 ****************
 8 :   138386: 0.14 *************
 9 :   111102: 0.11 ***********
10 :    83367: 0.08 ********
11 :    55799: 0.06 *****
12 :    27514: 0.03 **

Since this is using random when running, your numbers for each Bin may vary.