Comment on my approach whether it is possible please

I am going to write a program about the game for C++ using GUI and windows form like the following.

http://a2.mzstatic.com/us/r1000/046/Purple/12/cc/46/mzl.ibakfrzy.320x480-75.jpg
Please have a look.

A simple additon instead of that multiplication. Once clicked, that box will be replaced by the other. All box are randomly generate the number at the beginning. Timer is limited.

Here are my ideas:

My number range for addition is 1-100. First I would like to declare an array of 16 picturebox. It means I would like to link 1-100 to the picture represent 1-100(a big problem to me). Then, when started initializing, randomly generate 16 picture to 16 pictureboxes.

After that, I would like to choose randomly one of the picturebox to be the ans. And randomly return 2 numbers for the question. Just like if I choose 6, 2 and 4 will be returned.

After the question is shown, when player click on the picturebox, if it matches with the ans the number for correct ans will add 1. or else, add 1 to the number of wrong ans.

When Time is reached, return the number of correct and wrong answers then calculate the score.

My idea is mostly like this. But few things I am confused with.

1. Is it possible to link 1-100 to the picture represent 1-100?

2.What should I put in the picture source of the picturebox when i need to randomly generate 16 picture to 16 pictureboxes

3. Is it possible to choose randomly one of the picturebox to be the ans. And randomly return 2 numbers for the question?

4. Or...Is this approach feasible? How can it be better?


Thank you for all your help.




1. Sure. Put the pictures in the array P with elements 0 to 99 so that the picture related to integer i (from 1 to 100) is P[i-1]

2. I'm not familiar with the GUI library you're using, but I bet there is something similar to a set_picturebox_picture_source function.

3. Sure. First fill an array G (of 16 integers) with random numbers (from 2 to 100). Then generate a random integer g (0 to 15) and choose G[g] to be the answer. Then you need to choose such p and q that p+q = G[g]. randomly generate p (from 1 to G[g]-1) and calculate q = G[g]-p.

4. There is nothing wrong with this.
Topic archived. No new replies allowed.