Concept explainers
Tic-Tac-Toe Simulator
Create a JavaFX application that simulates a game of tic-tac-toe. Figure 12-38 shows an example of the application’s GUI. The GUI shown in the figure uses eight ImageView controls to display the Xs and Os. (You will find images for the X and the O in the book’s Student Sample Files.)
Figure 12-38 The tic-tac-toe application (Oracle Corporate Counsel)
The application should use a two-dimensional int array to simulate the game board In memory. When the user clicks the New Game button, the application should step through the array, storing a random number in the range of 0 through 1 in each element. The number 0 represents the letter O, and the number 1 represents the letter X. The application’s window should then be updated to display the game board. The application should display a message indicating whether player X won, player Y won, or the game was a tie.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Starting Out with Java: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (6th Edition)
Additional Engineering Textbook Solutions
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Starting Out With Visual Basic (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Management Information Systems: Managing the Digital Firm (15th Edition)
Starting Out with C++: Early Objects (9th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
- 10. Tic-Tac-Toe SimulatorCreate a JavaFX application that simulates a game of tic-tac-toe. Figure 15-55 shows anexample of the application’s GUI. The window shown in the figure uses nine ImageViewcomponents to display the Xs and Os. (You will find images for the X and the O in thebook’s Student Sample Files.)The application should use a two-dimensional int array to simulate the game board in memory. When the user clicks the New Game button, the application should step through thearray, storing a random number in the range of 0 through 1 in each element. The number 0 represents the letter O, and the number 1 represents the letter X. The application’s windowshould then be updated to display the game board. The application should display a messageindicating whether player X won, player Y won, or the game was a tiearrow_forward4.The "Clear" Button should erase the contents of all the fields and the textArea. It should also hide the car related fields and labels, as shown in Figure 2. 5.The "Exit" button should close the application by simply calling System.exit(0);Here are the classes: EmployeeController class: import javafx.fxml.FXML;import javafx.scene.control.Button;import javafx.scene.control.Label;import javafx.scene.control.TextArea; public class EmployeeController { @FXMLprivate Label NameEM; @FXMLprivate Label MakerEM; @FXMLprivate Label PriceEM; @FXMLprivate Button handlehascar; @FXMLprivate Button AddButton; @FXMLprivate TextArea TextAreaBox; } EmployeeApp Class: import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.layout.Pane;import javafx.scene.Scene;import javafx.stage.Modality;import javafx.stage.Stage; public class EmployeeApp extends Application { @Overridepublic void start(Stage stage) throws Exception{Pane root =…arrow_forward4.28 LAB: Temperature converter In this lab, you will implement a temperature converter in JavaScript. The user may type a temperature in either the Celsius or Fahrenheit textbox and press Convert to convert the temperature. An image displays based on the converted temperature. Download the ZIP file below containing HTML, JavaScript, and image files. The HTML file declares five UI elements: Element's ID Element description cInput Text input field for Celsius temperature fInput Text input field for Fahrenheit temperature convertButton Button that, when clicked, converts from one temperature to the other errorMessage Paragraph for displaying an error message when temperature cannot be converted weatherImage Image corresponding to the temperature Implement conversion functions (2 points) Implement the convertCtoF() and convertFtoC() functions to convert between Celsius and Fahrenheit. convertCtoF() takes a single numerical argument for a temperature in Celsius and…arrow_forward
- Extra 7-2 Add a stopwatch to the Clock application In this exercise, you’ll add a stopwatch feature to a digital clock application. The stopwatch will display elapsed minutes, seconds, and milliseconds. 1. Open the application in this folder: exercises_extra\ch07\clock_stopwatch\ 2. In the JavaScript file, note the $(), displayCurrentTime(), padSingleDigit(), and DOMContentLoaded event handler functions from the Clock application. In addition, note the global variables and starting code for the tickStopwatch(), startStopwatch(), stopStopwatch(), and resetStopwatch() functions. 3. In the tickStopwatch() function, add code that adds 10 milliseconds to the elapsedMilliseconds variable and then adjusts the elapsedMinutes and elapsedSeconds variables accordingly. Then, add code that displays the result in the appropriate span tags in the page. 4. In the startStopwatch() function, add code that starts the stopwatch. Be sure to cancel the default action of the link too. 5. In the…arrow_forwardCreate a Simple Swing application with the following properties: Import the Java package that contains all the classes we require to create swing app. Create a class called examSwing with private access specifier and do the following in the constructor of this the class. Create an object of the frame class and pass "Exam Pressure" to its constructor. Call the frame frmExam. Prevent the user from maximizing the frmExam frame. Set the width of frmExam to 300 pixels, and its height 200pixels Indicate that when the user clicks on the close button on frmExam, the frame should exit. Create an object ofthe label class. Call it lblexam and set its text to "Exam Fever" Position the lblexam 150pixels and 50pixels on the X and Y axis with a width and height of 100pixels and 20pixels respectively. Add lblexam to frmExam. Set the visibility property of frmExam to true.arrow_forwardmain.cc file #include "robotutils/robotclicklistener.h" //// You do not need to edit this file.// // Helper function to create robot*.bmp. Feel free to make your own// icons and use this for inspiration./*void CreateRobotIcon() { graphics::Image image(31, 31); // Arms image.DrawLine(0, 10, 10, 15, 109, 131, 161, 6); image.DrawLine(30, 10, 10, 15, 109, 131, 161, 6); // Legs image.DrawLine(10, 15, 10, 30, 109, 131, 161, 6); image.DrawLine(20, 15, 20, 30, 109, 131, 161, 6); // Body image.DrawRectangle(5, 0, 20, 22, 130, 151, 179); // Eyes image.DrawCircle(10, 8, 2, 255, 255, 255); image.DrawCircle(20, 8, 2, 255, 255, 255); image.DrawCircle(9, 8, 2, 62, 66, 71); image.DrawCircle(19, 8, 2, 62, 66, 71); image.SaveImageBmp("robot.bmp");}*/ int main() { RobotClickListener listener{}; listener.Start(); return 0;} robot.cc file #include "robot.h" #include <string> #include "cpputils/graphics/image.h" // ========================= YOUR CODE HERE =========================//…arrow_forward
- Implement the using Windows form App(.NET Framework) c# : 1- creat a Form titled “ Students ” 2- Add text box with max 100 letter, where student can enter his name 3- Add Grade combobox where student can select his grade (A-B-C-D-E-F) 4- Add button “Add”, when clicked the name and grade are added to the data view5- Add button “Stat” when clicked another form appears6- A data grid appears with grade vs count statistic (ex : A ,3 ) (please respond with screenshots )arrow_forwardConstruct the frame given bellow using JavaFx and do required operation on click of the button “Save”, “Delete”, “Update” and “Reset” respectively. Use File to store data. Follow the guidelines as described below Guideline: ∙ In GUI ID, Name, Telephone holds data from “TextField”, Address from “TextArea” and Dept. from a “ComboBox” with “Accounts”, “HR” and “IT” items. ∙ File Name: “java_test” ∙ On Click of “Save”: Save all data from GUI to File without duplicating the employee information. If the details are already in the file, show “Alert Message”. ∙ On Click of “Delete”: Delete the entry from the file ∙ On Click of “Update”: Update the required fields of the specified employee ∙ On Click of “Reset”: Clear all fieldsarrow_forwardReact Create hover calendar I have a calendar icon in react and I want to display a calendar when hovering over the calendar icon in react: here is code: <div className="date-choose pad-left-0 pad-right-0"> <span className="enhanced-sports enhanced-sports-calendar" /> </div>arrow_forward
- Java Script Create the following GUI. You do not have to provide any functionality. Suggested logic1. Create the main window JWindow (set it for BorderLayout)2. Create a JPanel (set it for GridLayout 4x4 to handle button components)3. Add the JPanel to the "South" area of the JWindow4. Create the buttons , add to the JPanel5. Create a JText or Jlabel, add to the "North" section of the JWindowarrow_forwardCreate a JavaFX application that simulates the rolling of a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use ImageView component to display the dice. (In the Student Sample Programs you will find six images named Die1.png, Die2.png, Die3. png, Die4.png, Die5.png, and Die6.png that you can use in the ImageView components.)arrow_forwardYou created a GUI in Scene Builder and saved it to a file named Testing.fxml. The GUI has a Button component with the fx:id myButton, and a Label component with the fx:id myLabel. You have already written the main application class. Write the code for the controller class. The controller class should have an event listener for the Button component that displays the string “Testing 1, 2, 3” in the Label component.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,