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

Edited by MatthewVb

3 Years
Discussion Span
Last Post by necrovore

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)



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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.