Prog 4: GridMatch
Write a program to display a 5 x 5 grid of small colored squares. Clicking with the mouse on any squares that is part of a group of 3 or more of the same color will make all of those squares disappear, with the ones above it sliding down. Each square on the board must be randomly initialized to one of 4 colors. Selecting the "Reset" button should again randomize all the board square colors. Selecting the "Exit" button should exit the program. The console window should display identifying information (name, date, etc.) as well as a summary of what is working and what is not working in your program.
Related sample code to get started can be found here, which are the solution files from the Spring 2011 Program #3 called Square-Up, which has many similarities. The big difference is that you must use arrays in this program.
Notes & Grading:
(5 points) Get the board to display as shown below, where the colors are randomly selected.
(5 points) Handle mouse clicks so that your program can identify which square was clicked. Set the color of the square that was clicked to "lightGray"
(20 points) Change the code that handles mouse clicks. When a square is clicked upon, see if it is part of a group of 3 or more. If so, change the color of all squares in that group to "lightGray." If a square is not part of a group of 3 or more, then no square should change colors as a result of the mouse click.
(25 points) Once a cluster of squares are set to "lightGray" then have any squares above them "slide down". Don't worry about nicely animating the sliding, just get the right colors to be in the right place.
Place all your program files into a single zip file and turn them in using Blackboard into the Program 4: GridMatch assignment.
Extra Credit:
(5 points) Once all playable configurations have been selected on a board with n squares per side, have your program automatically refresh, except this time with n+2 squares per side.
(5 more points) If an entire column is left blank, have the squares to the right of it slide left to fill in. For example, if we started with:
and then clicked on any one of the middle "gray" squares, then all those connected gray squares would be eliminated, leaving:
If the blank column is eliminated, that would leave: