a. In Chapter 9, you created a Tic Tac Toe game in which you used a 2D
Question:
a. In Chapter 9, you created a Tic Tac Toe game in which you used a 2D array of characters to hold Xs and Os for a player and the computer. Now create a JPanel that uses an array of nine JButtons to represent the Tic Tac Toe grid. When the user clicks a button that has not already been taken, place an X on the button and then allow the computer to place an O on a different button. Announce the winner when either the computer or the player achieves three marks in sequence, or announce that the game was a tie. Figure 16-44 shows a typical game in progress and after the player has won. Save the game as JTicTacToe.java.
b. Add a graphic that displays a large letter representing the winning player of the JTicTacToe game. Draw a large X, O, or, in case of a tie, an overlapping X and O in different colors. Save the game as JTicTacToe2.java.
Tic Tac Toe Tic Tạc Toe Choose one button Choose one button X Game over! You win! Figure 16-44 Typical execution of the JTicTacToe program
Step by Step Answer:
a import javaxswing import javaawt import javaawtevent public class JTicTacToe extends JPanel implements ActionListener JLabel greeting new JLabelTic Tac Toe JLabel promptLabel new JLabelChoose one bu...View the full answer
Students also viewed these Computer science questions
-
In Chapter 9 you created a database for the Wine Depot consisting of a Wine Products table, a Winery table, and a Buyer table. You also created an initial query, form, and report. Barbara has now...
-
In Chapter 9 you created a database for Kelly's Boutique consisting of a Book table, a Department table, and a Publisher table. You also created an initial form, query, and report. Kelly would now...
-
In Chapter 9 you created a database for the Snick's Board Shop consisting of a Products table, a Category table, and a Manufacturer table. You also created an initial query, form, and report. Caitlin...
-
Which of the following is not a suggested procedure to establish internal control over cash disbursements? The bank statement is reconciled monthly. Anyone can sign the checks. Blank checks are...
-
The construction of a histogram for a data set reveals that the distribution is approximately normal and the box plot is constructed with these quartiles: Q1 = 62, Q2 = 70, Q3 = 78. Estimate the...
-
Would you want to live in a smart city? Explain.
-
A viscous fluid flows past a flat plate such that the boundary layer thickness at a distance \(1.3 \mathrm{~m}\) from the leading edge is \(12 \mathrm{~mm}\). Determine the boundary layer thickness...
-
Granny Carney Associates surveys American eating habits. The companys accounts include Land, Buildings, Office Equipment, and Communication Equipment, with a separate Accumulated Depreciation account...
-
A company issued, 8 years ago, bonds with an annual coupon rate of 8% and a face value of $1000. The coupons are semi-annual and the maturity at the time of issue was 20 years. a. If the...
-
Jana leaves her trucks motor running while she enters a Kwik-Pik Store. The trucks transmission engages, and the vehicle crashes into a gas pump, starting a fire that spreads to a warehouse on the...
-
Write an application that extends JPanel and displays a phrase in every font size from 6 through 20. Save the file as JFontSizesPanel.java.
-
You developed an interactive GUI application for Carlys Catering. Now, design a JPanel that uses graphics to display a logo for the company, and modify the GUI application to include it. Save the...
-
In Exercises convert from radians to degrees or degrees to radians. 45
-
Outline the problems of open book accounting in practice.
-
A supply chain consists of three partners: the focal OEM with significant bargaining power and two smaller partners, an upstream supplier and a downstream retailer. Each supply chain layer holds some...
-
Explain the role of logistics in a modern economy.
-
What are the distinctive features of cost management when compared to cost accounting? Name and describe the three key focus areas of cost management.
-
Explain the concept of insurance as a typical risk transfer strategy.
-
On December 31, 2017, Zhang Ltd. rendered services to Beggy Corp. at an agreed price of $91,844.10. In payment, Zhang accepted $36,000 cash and agreed to receive the balance in four equal instalments...
-
The senior management at Davis Watercraft would like to determine if it is possible to improve firm profitability by changing their existing product mix. Currently, the product mix is determined by...
-
Write an application that uses a loop to create the pattern of Os shown in Figure 6-32, in which each O is displayed one additional space to the right. Save the file as DiagonalOs.java.
-
you created a program named Triangle in which you displayed a seven-line triangle pattern like the one in Figure 6-33 by using a series of println() statements. Now, using your knowledge of loops,...
-
Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entered is less than 0 or more than 10, display an appropriate message and do...
-
A farmer wonders if his crops grow better in sun or in shade. He measures the amount of fruit gathered from a sample of 50 trees growing in full sun and from a sample of 50 trees growing in mostly...
-
Consider the diagram. Determine the length of AC to the nearest cm. Determine the length of DC to the nearest cm. 28 38 A 224 cm 789 B
-
Use this picture to answer the following questions. 10 18 16. 3 AB=10 AC=16 AD=22 AE=15 BC-17 BD=18 15 BE=25 CD=26 CE=8 DE=11 Find the Nearest Neighbor Circuit for each vertex. Also give the weight...
Study smarter with the SolutionInn App