COMP 110 Summer 2011
Debugging Program 4
-
Program 4 can be hard to debug, because it might seem like you
need to have everything completely working before you can see
any progress. But in fact, you will see some changes in the
game behavior as you go along, as long as you implement them
in a reasonable order. Below are the results of one such
order.
-
After implementing displayHit:
Solution
Now a white
circle will appear in the upper left corner when the user
clicks somewhere.
-
After implementing getIconDisplayXLocation:
Solution
Now the
circle has the correct x location, so it will appear
in the center of the correct column.
-
After implementing getIconDisplayYLocation:
Solution
Now the
circle has the correct y location as well, so it will
appear in the center of the square clicked.
-
After implementing buildBoard and getColor:
Solution
Now
the gameBoard array has numbers in it that map to
colors. Clicking a square diplays a circle whose color
matches the number in that square. Since the board is not yet
randomized, the colors will be predictable (and the two halves
of the board should match).
-
After implementing swapSquares and randomizeBoard:
Solution
Now the
colors should be placed unpredictably.
-
After implementing updateSquareTracking
and wipeIncorrectSquares:
Solution
Now after
clicking two squares, they will both disappear after 1 second.
-
After implementing isCorrectMatch
and markSquaresAsCorrect:
Solution
Now
matching pairs of squares will stay on the board instead of
disappearing.
-
After implementing legalSquare:
Solution
Now users
aren't allowed to choose the same square twice or to pick
squares that have already been guessed correctly.
-
After implementing totallySolved:
Solution
Now after
all the squares have been successfully guessed, the game will
display a message that the player has won.
-
Finally, after implementing wipeBoard, you would have
the complete game as given on the program assignment page.
Now the game will restart when the user clicks again after
having won.