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...
-
Strite Company issues $2 million, 10-year, 7% bonds at 99, with interest payable on December 31. The straight-line method is used to amortize bond discount. (a) Prepare the journal entry to record...
-
Micaela works for a sprinkler maintenance company and runs a routine check on the Harris's sprinkler system every third month. If Micaela checks the system in an April, what month will it be when...
-
Analysis of Given Ratios Robbins Company is a wholesale distributor of professional equipment and supplies. The company?s sales have averaged about $900,000 annually for the 3-year period 2009?2011....
-
Compute the expected return given these three economic states, their likelihoods, and the potential returns: Economic State Probability Return Fast Growth 0.40 25 % Slow Growth 0.55 12 % Recession...
-
You will develop a program that loads student, course, and grade data from a text file, then allows the user to perform simple queries on that data through a command line interface. The intention of...
-
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...
-
Describe the major leadership styles.
-
Answer the following questions about the characteristics of a corporation's shares: 1. Who are the real owners of a corporation? 2. What privileges do preferred shareholders have over common...
-
Which of the following most likely would be called an assurance service? a. Performance measurement. b. Tax planning. c. Personal financial planning. d. Systems design and implementation.
-
Colonoscopy is a medical procedure that is designed to find and remove precancerous lesions in the colon before they become cancerous. In a sample of 51,460 people without colorectal cancer, 5043 had...
-
In a poll of 100 voters, 57 said they were planning to vote for the incumbent governor, and 48 said they were planning to vote for the incumbent mayor. Explain why these data should not be used to...
-
Which two IFAC future-ft accounting roles require the strongest strategic digital technology competencies?
-
Richards Company had the following budgeted sales for the first half of 2007: How much is the budgeted accounts receivable balance on April 30, 2007? Collections on sales: 60% in month of sale 30% in...
-
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...
-
An employee received an option to purchase shares of a public company at $8 per share when the price of the stock was $10 per share. Ihe ($)/(_()) difterence creates a taxable benefit that is taxed...
-
The cost of goods sold for Frye Manufacturing in the year was $233,000. The January 1 Finished Goods Inventory balance was $31,700, and the December 31 Finished Goods Inventory balance was $25,200....
-
S Fill in the missing amounts in each of the eight case situations below. Each case is independent of the others. (Hint: One way to find the missing amounts would be to prepare a contribution format...
Study smarter with the SolutionInn App