563 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The idea behind this exercise is to create a game of pairs. At the end of this explanation of how the game should work some ideas are given - it's up to you whether you take advantage of these!
Let's start with how your system should work. When you first start, you should see a form containing 18 buttons:
Initially only the Deal button is available.
When you click on the Deal button, your system should randomly assign the owl pictures available (see later in this exercise for how to get these) to the buttons as 9 pairs:
One iteration of the program - each one will look different.
When you click on the Start button you can start playing:
Here we've already got 2 pairs, but the third guess is wrong, and the unmatched pair will revert back to grey in a second.
When you've got all of the pairs, the system should show a congratulatory message, then close down the form.
The 9 owl pictures that you'll need are in the folder above. Having added them into your project, you can drag them into a resources file:
Select the images and drag them into an open .resx file.
Thereafter you could access an image to assign to a button using something like this:
public static System.Drawing.Image ImageToUse(int OwlNumber)
You can remove an image by setting the Image property of a button to null. To keep track of which image is assigned to which button, the answer uses the Tag property of each button, which is a string of text used for no other purpose than to tag any form control.
A suggestion for how to loop over the buttons follows ...
If you know how to loop over collections, do so. Otherwise, you can loop over the 18 buttons on a form as follows:
// loop over all 18 buttons
for (i = 1; i <= 18;="">
// refer to the button by name (note that you have to cast the
// control to a button
Button b = (Button)this.Controls["Button" + i.ToString()];
// do something to button (here we remove the image)
b.Image = null;
There's no right or wrong way to solve this, but here are the classes used in the answer:
Used to refer to each button.
Used for a single turn (ie the action of choosing two pictures).
Some other useful ideas ...
After an unsuccessful guess, you'll want to hide the two buttons chosen. Here's one command to do this:
// wait for 1000 milliseconds (1 second)
To allocate the buttons initially, the answer creates this variable:
// holds unassigned buttons
owlsLeft = "112233445566778899";
Whenever an owl picture is assigned, the relevant number is removed from the list. This ensures each owl is assigned twice, and twice only. Inelegant, but it works! Good luck ...
25 Aytoun Street