Question
In Java please. Show correctly the code and the output. CODE REQUIRED import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.Pane; public class SliderPuzzleView extends Pane
In Java please. Show correctly the code and the output.
CODE REQUIRED
import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.Pane; public class SliderPuzzleView extends Pane { public static final int GRID_UNIT_SIZE = 40; private Button[][] gridSections; private Button startButton, nextBoardButton; private TextField numMovesField; private SliderPuzzleGame model; public SliderPuzzleView(SliderPuzzleGame m) { model = m; gridSections = new Button[GameBoard.WIDTH+2][GameBoard.HEIGHT+2]; // Create the wall (i.e., non-pressable) buttons for (int i=0; i GRID (2) The View We will now create the View for the application which will show the game's state Slide Puzzle Application at any time. The view is shown in the image GRID here. Each square in the grid is a Button UNIT The buttons along the border are disabled, SIZE so that the user cannot click on them. The code for adding all the grid buttons has been given to you (see code below) You just need to write the code to add the Start and Next Board buttons as well as the number of moves TextField. Finally, you must carefully write the update() method which must behave as follows: All grid buttons should have their color reset to white each time update0 is called All grid buttons that belong to a particular game piece should be colored according to that game piece. For example, grid buttons at positions (5,3), (5,4) and (5,5) will be colored blue, while grid buttons at 100 1000 positions (0,2) and (0,3) will be 100 100 colored red. Note that you can call the setStyle0 method for a button to set its color as follows: setStyle fx-base: gp get color .toString substring where gp is the gamePiece at that button's location. The Start button should be disabled if we are not waiting to start a board. The NextBoard button should be disabled if we are waiting to start a board All grid buttons should be disabled if a board is not in progress (i.e., disable when a board has just been completed). The number of moves made on the board so far, should be displayed right-aligned in the TextField The next page shows a sequence of screen snapshots showing how everything should look as the game is played. The top left image is what you should see upon start-up, with all buttons disabled, except the Start button. Then after the Start button has been pressed, the grid buttons are enabled, the NextBoard button is enabled and Start is disabled. Once the board has been completed by sliding the GoalPiece out, then the buttons are all disabled again, except for the NextBoard button
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started