MDM4U – Writing a Versatile Dice Simulator (optional)

(A student recently asked for ideas for applications to write. This is one response to that request. I use this task in my ICS3C/3U course online, in Java. Dear students: you don’t need to complete this task.)

In many role-playing games, players develop new characters by rolling a die or dice a number of times.

Write an application with a graphical user interface which simulates this activity and displays the result.

The user decides two parameters:

  • how many rolls to simulate
  • how many sides each die has

For example, the user might want 10 rolls of a standard, six-sided die (called a d6, if you’re interested). The user might later want 300 rolls of a 10-sided die (you guessed it: d10).

You’ll design the interface as you see fit, as long as the results are displayed in a JTextArea in a column, like this:


Make sure you handle bad user input gracefully (e.g. your program shouldn’t crash if the user enters “potatoes” for the number of rolls to simulate).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s