Question: Create the game Lights Out using a BorderLayout. Place a five-by-five grid of panels in one region, and reserve another region for a congratulatory message.
Create the game Lights Out using a BorderLayout. Place a five-by-five grid of panels in one region, and reserve another region for a congratulatory message. Randomly set each panel in the grid to a dark color or light color. The object of the game is to force all the panels to be dark, thus turning the “lights out.”When the player clicks a panel, turn all the panels in the same row and column, including the clicked panel, to the opposite color. For example, if the user clicks the panel in the second row, third column, then darken all the light-colored panels in the second row and third column, and lighten all the dark-colored panels in that row and column. When all the panels in the grid are dark, all the lights are out, so display a congratulatory message. Save the game as LightsOut.java.
Step by Step Solution
3.46 Rating (172 Votes )
There are 3 Steps involved in it
import javaawt import javaxswing import javaawtevent import javautil import javaawtColor public class LightsOut extends JFrame implements MouseListene... View full answer
Get step-by-step solutions from verified subject matter experts
