Create the game Lights Out using a BorderLayout. Place a five-by-five grid of panels in one region,
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. 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 Answer:
import javaawt import javaxswing import javaawtevent import javautil import javaawtColor public class LightsOut extends JFrame implements MouseListene...View the full answer
Students also viewed these Computer science questions
-
a. Create aMine Field game in which the user attempts to click 10 panels of a grid before hitting the bomb. Set up a JFrame using BorderLayout, use the NORTH region for a congratulatory message, and...
-
Create aMine Sweeper game by setting up a grid of rows and columns in which bombs are randomly hidden. You choose the size and difficulty of the game; for example, you might choose to create a fairly...
-
You set up the card game Concentration by placing pairs of cards face down in a grid. The player turns up two cards at a time, exposing their values. If the cards match, they are removed from the...
-
2. Cash basis $(3,400)Fantastic Catering completed the following selected transactions during May 2016: May 1 Prepaid rent for three months, $1,800. 5 Received and paid electricity bill, $200. 9...
-
Based on the sample results in Data Set 18 of Appendix B, assume that human body temperatures are normally distributed with a mean of 36.4C and a standard deviation of 0.62C. What two temperature...
-
A geometric progression has first term a and common ratio r. The sum of the first three terms is 3.92 and the sum to infinity is 5. Find the value of a and the value of r.
-
What does integrity mean in the context of data management?
-
Xania Inc. uses a normal job-order costing system. Currently, a plantwide overhead rate based on machine hours is used. Xania's plant manager has heard that departmental overhead rates can offer...
-
What happens when spectrometer gives negative values? Why?
-
Estimate the number of grains of sand on the beaches of the major continents of the earth. Exclude islands and inland bodies of water. You should come up with a number somewhere near Avogadros number.
-
Write an application that lets you determine the integer value returned by the InputEvent method getModifiers() when you click your left, right, orif you have onemiddle mouse button on a JFrame. Save...
-
a. Search the Java Web site for information on how to use a JTextArea. Write an application for the WebBuy Company that allows a user to compose the three parts of a complete e-mail message: the To:,...
-
With reference to the "Chemistry Put to Work" box on explosives, (a) Use bond enthalpies to estimate the enthalpy change for the explosion of 1.00 g of nitroglycerin. (b) Write a balanced equation...
-
In hurricane season 2023, we saw the impacts of Hurricane Idalia, which hit the Florida Panhandle at the end of August. We have talked a lot this semester about environmental issues and about the...
-
Selected current year-end financial statements of Cabot Corporation follow. (All sales were on credit; selected balance sheet amounts at December 31 of the prior year were inventory, $52,900; total...
-
You are a research analyst interested in how dividends affect stock prices. Assume that there is only one income tax rate (i ) and a capital gains rate (c ). Also assume that the owner has held the...
-
Directness. How would you describe the level of directness you use when talking face to face versus the level you use in texting or in e-mail or chat rooms? If you do notice differences, to what do...
-
A grinding mill in the Free State Province breaks down on average 5 times a month. What is the probability that the mill will not break down in a month?
-
Which balance-related audit objectives are not affected by control risk for classes of transactions? Why?
-
Tiger, Inc. signed a lease for equipment on July 1, 2007.The lease is for 10 years (the useful life of the asset).The first of 10 equal annual payments of $500,000 was made on July 1, 2007.The...
-
Modify the Card class so the setValue() method does not allow a Cards value to be less than 1 or higher than 13. If the argument to setValue() is out of range, assign 1 to the Cards value. You also...
-
You created a Die class from which you could instantiate an object containing a random value from 1 through 6. You also wrote an application that randomly throws two dice and displays their values....
-
In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they...
-
Shahid Pakistan Limited (SPL) is engaged in the production of three products: J, K and L. Following is the extract from its latest annual management accounts: Description J Products K Total L Units...
-
John Company produces hats and sells them for $100 each. His cost to produce the hats are: DM 20 per unit DL 30 per unit VMOH 10 per unit FMOH 40,000 Selling expenses are $5 per unit and are all...
-
John Company produces hats and sells them for $100 each. His cost to produce the hats are: DM 20 per unit DL 30 per unit VMOH 10 per unit FMOH 40,000 Selling expenses are $5 per unit and are all...
Study smarter with the SolutionInn App