English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to write a program for a simple game in which each of two players rolls a pair of dice. The person with the highes tally wins. The program should use a Game class having two member variables of the type PairOfDice.

I need help with the class. How would I go about programming this question?

2007-11-25 00:18:46 · 1 answers · asked by Tyna 1 in Computers & Internet Programming & Design

1 answers

Break the task down into simple steps. You can then program a function to do each simple step. Then combine these simple functions in a larger program.

For example you dice game requires dice. So make a function to simulate a single die which returns a randome number from 1 to 6.

Call this routine as many times as needed based upon the number of dice rolled. (two in this case)

Make another function which totals a player score, and another function which compares two players scores and tells which one wins.

2007-11-25 00:27:10 · answer #1 · answered by MarkG 7 · 0 0

fedest.com, questions and answers