7
Reply

Need help with C# program

zero cool

zero cool

Sep 7 2012 12:30 PM
3.4k
Forms based game, you will have:

- A 4x4 array of square buttons. You will name each of these buttons differently, from Button_0_0 to Button_3_3
-A button which reads "New game"
-A non-editable text box where you will display feedback for the user

When the new game button is pressed:
- you will randomly choose the X coordinate [0-3] and Y coordinate [0-3] of the button that contains the "treasure". You will save these randomly chosen X and Y coordinates in the two int data members named treasureX and treasureY of the form (you have to add these two data members outside the callback but inside the form class code.

When the user presses one of the 16 buttons, you will:
-Check to see if the X and Y coordinate of the button matches the treasureX and treasureY coordinate. if so,
        - You will report to the user "You found the treasure!", otherwise
        -You will report to the user "Sorry there is no treasure here!"
This will require you to define 16 callback functions, one for each button

To get a random integer consider the following code

Random r = new Random();
int x = r.Next (100, 200);

which will set x between 100 and 199 inclusive (it will never return 200)

Answers (7)