FontysICT-sem1

Training - For - Roll generator

In many board games (or digital variants thereof) throws are made with multiple dice (especially in games like Yahtzee, Risk, etc.).

If you don’t have dice at hand or you’re programming a digital variant of a game, a program that can roll x number of dice with y number of pips comes in handy.

The program you created at the end of this assignment looks like this:

ui ![[Worpengenerator-ui.png]]

Part 1.

Create a new C# Windows Forms project. Create a user interface which looks like the one below (this is a simplified form of the final result, we will assume dice with 6 pips for now). The boxes (Settings and Results) are GroupBox objects. These allow you to put a number of GUI objects that belong together as a group and later, if necessary, move them e.g. as a whole. It is most convenient to create the GroupBox objects first so that you can put the other objects on this. The white output area is a ListBox.

ui1

Tips

Part 2

Expand the user interface with two Label objects like the one below. One contains the text “Total number of eyes:”, the other contains the default value “0” and will later contain the total number of eyes for the roll. Give the Label objects clear names.

ui

In the EventHandler of the Button, make sure to add the code that tracks the total number of eyes thrown. Use a “totalEyes” variable of type int for this purpose.

Tips

Part 3

Expand the user interface with a Label and a NumericUpDown as shown below. The Label will have the text “eyes on die”, the NumericUpDown will have a minimum value of 2 and a maximum value of 100. The default value will be 6 (since this is the most common amount of eyes on a die).

ui

Ensure that instead of a value of 1 to 6, a value of 1 to the value in the new NumericUpDown is now generated.

Extensions

Checklist

If you have completed the task correctly you have fulfilled the points below: