I used an array of type boolean to represent the pegboard. There are a total of ten holes on the board, so my array contains ten boolean variables, one for each hole. I use false to mean that the hole is not yet filled, so initially all elements of my array must be false when the game starts. Happily, this is the "default" value for boolean, so I needn't actually need to do anything special to initialize the board.
You may find it more convenient to declare your array to be of length 11. This way there is a direct correlation between the number labeling the peghole and the index into the array (if you just ignore the zero element.)
The player wins when all pegholes on the board have been filled. This happens when 10 pegs have been placed successfully.
Naturally, you want to avoid sprinkling the constant 10 throughout your program. What if you later decide to use 9 or 11 pegholes in your game? In run, I make the following declaration:
int numHoles = 10;
Then, I use numHoles whenever I need to refer to the size of my pegboard.
You need to "abort" the current game, resetting all the pegholes in the board to be "unfilled", and then start playing a new game. This may necessitate stopping one or more loops.
I detect a click on the restart button inside my getClick function. This function handles all the mouse reads, ignoring all "bad clicks". If a legal, unfilled peg is clicked, then getClick returns the peg number (1, 2, 3, ... or 10). If the restart button is clicked, getClick returns a -1. This way the calling function can detect whether or not the restart button was pressed.
The bad clicks can be determined by the x-coordinate of the click. These are all "bad clicks" and should be ignored:
All I can say is that if you choose a good coordinate system, then this check can be done arithmetically. That is, it is not necessary to keep an array of the circles used to draw the holes. You should be able to compute the center point of the "nearest" circle based on the x-coordinate of the clicked point.
Sure, I'd call that a win...