hey guys,

im trying to create a dice cricket game where u use 2 buttons, one for each innings and then use a random number generator for the number 1-6. i understand all that code but im not to sure how to write code to collect and sum numbers 1, 2, 3, 4 and 6 and store them in memory while rolling a 6 causes the batsman to go outand once all 10 batsmen are out the innings is over and the total runs scored is stored and displayed. any help would be much appreciated thanks

Recommended Answers

All 2 Replies

how about storing your numbers in an array or my.settings?

If u are only keeping track of score then you only need a score variable that will be incremented after each roll of the dice (which is one ball). But there are limitations to this, you would not be avle to pull out statistics like avg runs per over, highest scoring over and sorts.
From what i understand from the post i think a multidimensional array would suite well.

1 2 3 4 5 6 (balls per over)

1
2
3
4
5
.
.
.

50
(over)

If the batsmen becomes out in a ball i would mark a -1(or any unusual number there, will have to be handled when u make your calculations for avg score and other things). to keep track of number of wickets thats has gone down i think its best to just use a variable.

IF the requirements will go up then i think i will make a class structure instead. I reckon a class structure should make it more manageable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.