DiceSimulator + runSimulation(int numberRolls):DiceAccumulator DiceSimulator - C
ID: 3759849 • Letter: D
Question
DiceSimulator + runSimulation(int numberRolls):DiceAccumulator DiceSimulator - Controls the running of the dice simulation. • runSimulation – Does the simulation of throwing two die. Determines how many times they both have the same number and accumulates the totals. Pseudocode : Dice Simulator runSimulation Algorithm CREATE DiceAccumulator object CREATE two Die objects REPEAT the number of times indicated by the numberRolls value passed into the method. Roll the first die Roll the second die IF spots on each die are the same IF spots = 1 CALL addSnakeEyes ELSE IF spots = 2 CALL addTwos ELSE IF spots = 3 CALL addThrees ELSE IF spots = 4 CALL addFours ELSE IF spots = 5 CALL addFives ELSE CALL addSixes END ELSE IF END IF END
Explanation / Answer
DiceSimulator + runSimulation(int numberRolls):
DiceAccumulator DiceSimulator - Controls the running of the dice simulation. • runSimulation – Does the simulation of throwing two die. Determines how many times they both have the same number and accumulates the totals. Pseudocode : Dice Simulator runSimulation Algorithm CREATE DiceAccumulator object CREATE two Die objects REPEAT the number of times indicated by the numberRolls value passed into the method. Roll the first die Roll the second die IF spots on each die are the same IF spots = 1 CALL addSnakeEyes ELSE IF spots = 2 CALL addTwos ELSE IF spots = 3 CALL addThrees ELSE IF spots = 4 CALL addFours ELSE IF spots = 5 CALL addFives ELSE CALL addSixes END ELSE IF END IF END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.