Back to Challenge Set 16

Code Challenge: Dice Roller

Difficulty  

divider

The Brief

What they asked for
For the game club. I need to roll any dice, not just
six-sided ones. Number of dice and how many sides. Give
me each roll and the total.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Two parameters, and both must genuinely change the behavior.
  • One method rolls a single die and returns the number — Activity 1.15's Random.Shared.Next with its + 1. Another calls it several times and returns the total. A method calling a method.
  • Test with one side. It is a silly input and it should still work: every roll is 1.

Sample Output

Sample Output
Rolling 3d6: 6 1 6
Total: 13

Your rolls will be different. Run it several times; the total must always equal the rolls added up.


Submit

Your requirements list and your program file, named cc-dice-roller.

Commence Challenge