Skip to content

Instantly share code, notes, and snippets.

@bhnascar
Created April 25, 2016 14:11
Show Gist options
  • Save bhnascar/04fa01e5e3f16a327795ac2c8d861aa0 to your computer and use it in GitHub Desktop.
Save bhnascar/04fa01e5e3f16a327795ac2c8d861aa0 to your computer and use it in GitHub Desktop.
Free response #1
Let's write a dice simulator. I want you to write a class that can
create an n-sided dice and simulate a dice-roll. In other words, given
n, you will create a "dice" with n faces numbered 1...n. To "roll" the
dice, you will basically pick a random integer between 1 and n.
The class should be able work like this:
Dice d1 = new Dice(6);
d1.roll(); // Returns random number between 1 and 6
d1.roll(); // Returns another random number between 1 and 6
...etc...
Dice d2 = new Dice(8);
d2.roll(); // Returns a random number between 1 and 8
...etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment