Lab 3.3 - Dice Machine
When most people think of dice, they think of little six-sided cubes with numbers
on them. However, there are many more types of dice with different sides.
Create an application that takes a number of sides from the user and
then rolls a virtual die with that many sides. Your program should
error-check the number of sides given to make sure that it's greater than
zero; if it isn't greater than zero, the program should display a message box explaining the problem to the user in a way that the user will learn how to fix the problem. Otherwise, it should
display a random number (a whole number, thank you) between 1 and the
number given by the user.
Here's an object list (aren't I nice?):
- A set of RadioButtons that give the traditional polyhedral dice sizes: 4-sided, 6-sided, 8-sided, 10-sided, 12-sided, 20-sided, and 100-sided. Make user-entered input an eighth option.
- A Text Box for the user's input in the eighth option, with a Label to tell the user the purpose of the Text Box.
- A Label for displaying the result (or the error message) with another Label indicating that it's the result.
- A Button to make the rolling happen. When it is clicked, it should generate a random number using the formula from the lecture (the one in your notes; you did take notes, right?). The low number is 1, and the high number is the value given by the user.
As always, design a useful and proper interface. It would be nice if you didn't use the same random seed each time the program runs. You may assume the user isn't a goob and will enter numerical values.
Common mistakes include:
- Not setting the TextAlign property to Right in TextBoxes intended for numeric input.
- Using unnecessary global variables.
- Not checking the user input for a valid value.
- Massively cascading "waterfall" If-Then-Else code.
- Not leaving enough space to display the full result.
- Wasting real estate or cutting off the title of the program.