simulate a pair of dice.

Simulation.java 703B

12345678910111213141516171819202122232425262728293031
  1. public class Simulation
  2. {
  3. int numOfDice;
  4. int toss; //number of toss I want to toss
  5. public Simulation(Integer numOfDice,Integer toss){
  6. this.numOfDice = numOfDice;
  7. this.toss = toss;
  8. }
  9. public void runSimulation(){
  10. Bin binny = new Bin();
  11. Dice dice = new Dice(numOfDice);//need to know how many dice to roll
  12. for (int i=1;i<=toss;i++){
  13. binny.setBin(dice.tossAndSum());// put the toss value in the bin
  14. }
  15. printResults(binny);
  16. }
  17. public void printResults(Bin binny){
  18. for(int i=2;i<=12;i++){
  19. System.out.println("SumOfToss " + i + " NumofResult " + binny.getBinValue(i));
  20. }
  21. }
  22. }