Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 16.12, Problem 16.12.2CP
Program Plan Intro
JavaFX:
Swing is also replaced by a new platform called as JavaFX.
- It integrates a modern GUI technology which permits to develop rich GUI applications.
- JavaFX contains built-in 2D, 3D and animation support.
Tic-Tac-Toe Game:
- Tic-Tac-Toe is a game generally played by two players, who takes turns by making an available cell in a 3x3 grid with their respective tokens.
- The tokens will be represented by either X or 0.
- Whenever a player places all the three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and it indicates that player has won the game.
- A draw occurs when all the cells on the grid are filled with tokens and neither player has won the game.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
when coding a chess game, implement the following method:
isInCheck(Side s): Returns true if the king of side s is attacked by any of the opponent’s pieces, i.e., if in the current board state, any of the opponents pieces can move to where the king is. Otherwise, it returns false. Note that this method is only used to warn the player when they are in check. You can use the GUI to test if this is working.
public boolean isInCheck(Side side) {
// TODO write this method
return false;
}
public enum Side {
BLACK, WHITE;
public static Side negate(Side s) {
return s == Side.BLACK ? Side.WHITE : Side.BLACK;
}
}
You have a board divided into N xN squares and two robots, R1 and R2. Each square on
the board has a number written on it R1 starts at the top left corner square of the board
and R2 starts at the top right corner square of the board. Your aim is to move the
robots so that R1 reaches the bottom right corner square and R2 reaches the bottom
left corner square. You have a remote control with two buttons, blue and yellow, that
control the robots as follows.
• Whenever you press the blue button, R1 moves one square to the right and
R2 moves one square down.
• Whenever you press the yellow button, R1 moves one square down and R2
moves one square left.
The robots are not allowed to move off the board-if pushing a button would force
either one of the robots to move off the board, the button push has no effect and both
robots stay where they are. For each robot, you compute a score which is the sum of
the numbers on the squares that it visits along the path that it follows from its starting…
What value is returned if you get the machine’s balance after it has printed a ticket?
Chapter 16 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Ch. 16.2 - Prob. 16.2.1CPCh. 16.2 - Prob. 16.2.2CPCh. 16.2 - Prob. 16.2.3CPCh. 16.2 - Prob. 16.2.4CPCh. 16.3 - How do you create a button with a text and a node?...Ch. 16.3 - Prob. 16.3.2CPCh. 16.3 - Prob. 16.3.3CPCh. 16.4 - What is the output of the following code? public...Ch. 16.4 - Prob. 16.4.2CPCh. 16.4 - Prob. 16.4.3CP
Ch. 16.4 - Prob. 16.4.4CPCh. 16.5 - Prob. 16.5.1CPCh. 16.5 - Can you apply all the methods for Labeled to...Ch. 16.5 - Prob. 16.5.3CPCh. 16.5 - Prob. 16.5.4CPCh. 16.6 - Prob. 16.6.1CPCh. 16.6 - Can you apply all the methods for TextInputControl...Ch. 16.6 - Prob. 16.6.3CPCh. 16.6 - Prob. 16.6.4CPCh. 16.7 - Prob. 16.7.1CPCh. 16.7 - Prob. 16.7.2CPCh. 16.7 - Prob. 16.7.3CPCh. 16.7 - Prob. 16.7.4CPCh. 16.8 - Prob. 16.8.1CPCh. 16.8 - Prob. 16.8.2CPCh. 16.8 - Prob. 16.8.3CPCh. 16.8 - Prob. 16.8.4CPCh. 16.9 - Prob. 16.9.1CPCh. 16.9 - Prob. 16.9.2CPCh. 16.9 - Prob. 16.9.3CPCh. 16.9 - How do you obtain the selected items and selected...Ch. 16.10 - Prob. 16.10.1CPCh. 16.10 - Prob. 16.10.2CPCh. 16.10 - Prob. 16.10.3CPCh. 16.11 - Prob. 16.11.1CPCh. 16.11 - Prob. 16.11.2CPCh. 16.11 - Prob. 16.11.3CPCh. 16.12 - Prob. 16.12.1CPCh. 16.12 - Prob. 16.12.2CPCh. 16.12 - How does the program check whether a player wins?...Ch. 16.13 - Prob. 16.13.1CPCh. 16.13 - Prob. 16.13.2CPCh. 16.13 - Prob. 16.13.3CPCh. 16.14 - Prob. 16.14.1CPCh. 16.14 - Prob. 16.14.2CPCh. 16 - Prob. 16.1PECh. 16 - Prob. 16.2PECh. 16 - (Traffic lights) Write a program that simulates a...Ch. 16 - (Create a miles/kilometers converter) Write a...Ch. 16 - (Convert numbers) Write a program that converts...Ch. 16 - (Demonstrate TextField properties) Write a program...Ch. 16 - Prob. 16.7PECh. 16 - (Geometry: two circles intersect?) Write a program...Ch. 16 - (Geometry: two rectangles intersect?) Write a...Ch. 16 - (Text viewer) Write a program that displays a text...Ch. 16 - (Create a histogram for occurrences of letters)...Ch. 16 - Prob. 16.12PECh. 16 - (Compare loans with various interest rates)...Ch. 16 - (Select a font) Write a program that can...Ch. 16 - (Demonstrate Label properties) Write a program to...Ch. 16 - Prob. 16.16PECh. 16 - Prob. 16.17PECh. 16 - (Simulation a running fan) Rewrite Programming...Ch. 16 - Prob. 16.19PECh. 16 - Prob. 16.20PECh. 16 - (Count-down stopwatch) Write a program that allows...Ch. 16 - (Play, loop, and stop a sound clip) Write a...Ch. 16 - (Racing cars) Write a program that simulates four...Ch. 16 - (Slide show) Programming Exercise 15.30 developed...Ch. 16 - Prob. 16.29PECh. 16 - (Pattern recognition: consecutive four equal...Ch. 16 - (Game: connect four) Programming Exercise 8.20...
Knowledge Booster
Similar questions
- 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 choose differently, the winner is determined as follows: Rock beats scissors, because a rock can break a pair of scissors. Scissors beats paper, because scissors can cut paper. Paper beats rock, because a piece of paper can cover a rock. Create a game in which the computer randomly chooses rock, paper, or scissors. Let the user enter a number 1, 2, or 3, each representing one of the three choices. Then, determine the winner. Program should validate all user input Game should ask the user to play again and continue if yes and stop if no. Once the user stops playing, program should print the total number of wins.arrow_forwardIn 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 choose differently, the winner is determined as follows:Rock beats scissors, because a rock can break a pair of scissors.Scissors beats paper, because scissors can cut paper.Paper beats rock, because a piece of paper can cover a rock.Create a game in which the computer randomly chooses rock, paper, or scissors.Let the user enter a number 1, 2, or 3, each representing one of the three choices.Then, determine the winner.Program should validate all user inputGame should ask the user to play again and continue if yes and stop if no.Once the user stops playing, program should print the total number of wins.arrow_forwardUsing java card Graphic GUI, create a card game with a card layout in which 13 cards are displayed and if that card has the king of heart, then lose if not the player winsarrow_forward
- JAVASCRIPT - When the "draw" button is pressed, 5 random cards are displayed. - The 5 random cards displayed are unique (no duplicates). - When a card is dragged and dropped onto another card, the cards swap.arrow_forwardIn 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 choose differently, the winner is determined as follows: Rock beats scissors, because a rock can break a pair of scissors. Scissors beats paper, because scissors can cut paper. Paper beats rock, because a piece of paper can cover a rock. Create a game in which the computer randomly chooses rock, paper, or scissors. Let the user enter a character, r, p, or s, each representing one of the three choices. Then, determine the winner. Save the application as RockPaperScissors.cs.arrow_forwardWho Wants to Be a Millonalre? You are a contestant on "Who Wants to be a Millionaire?" You already have answered the $250,000 question correctly and now must decide if you would like to answer the $500,000 question. You can choose to walk away at this point with $250,000 in winnings or you may decide to answer the S500,000 question. If you answer the $500,000 question correctly, you can then choose to walk away with $500,000 in winnings or go on and try to answer the $1,000,000 question. If you answer the $1,000,000 question correctly, the game is over and you win $1,000,000. If you answer either the $500,000 or the $1,000,000 question incorrectly, the game is over immediately and you take home "only" $32,000. A feature of the game "Who Wants to be a Millionaire?" is that you have three "lifelines"-namely "50-50," "ask the audience," and "phone a friend." At this point (after answering the $250,000 question), you already have used two of these lifelines, but you have the "phone a…arrow_forward
- Force Completion This test can be saved and resumed at any polnt until time has expired. The timer will continue to run if you leave the test. Remaining Time: 49 minutes, 11 seconds. * Question Completion Status: A Moving to another question will save this response. « > Question 4 8 points Save Answer (10101)2 xor (10111)2 = (abcde)2 based on the equation calculate ((not b or d) and e). A Moving to another question will save this response. « »arrow_forwardIn this lab session, you are going to improvement a simulator for an air conditioner. Users can select sort of actions that the air conditioner allows. Turn air conditioner On/Off Increase fan speed by 100 Decrease fan speed by 100 Change to mode of cooling: On/Off Increment the temperature degree of the air conditioner Decrement the temperature degree of the air conditioner Exit the program: -------------------------------------------------------------------------------------------------------------------------------------------------------- #include <stdio.h> #define true 1 #definefalse0 #define MinFan 100 #define MaxFan 1000 #defineMinCool18 #define MaxCool 30 typedef int bool; typedef struct AirConditionerStruct { bool status; // running status struct FanStruct{ bool flow; int fanSpeed; } fanControl; struct ModeStrcut{ bool cooling; int degree; } coolingControl; }AirConditioner; void changeStatus (AirConditioner *airPtr); void increaseFanSpeed (AirConditioner…arrow_forwardScenario You work for a small company that creates text-based games. You have been asked to pitch an idea to your team for a text-based adventure game with a theme and environment of your choice. Your game must include different rooms, items, and a villain. The basic gameplay will require the player to move between different rooms to gather all of the items. A player wins the game by collecting all the items before encountering the villain. The player will have two options for commands in the game: moving to a different room, and getting an item from the room they are in. Movement between rooms happens in four simple directions: North, South, East, and West. Directions In this project, you will break the problem down into a set of requirements for your game program. Then you will design your game by creating a storyboard and pseudocode or flowcharts. Remember, in Project One, you are only designing the game. You will actually develop the code for your game in Project Two. Review the…arrow_forward
- Use timer event to write a simple game to be played in a JFrame. One of your pictures is jumpingin the frame, showing up in randomly selected places. Whenever the user catches the picture withmouse, the picture will stop moving. When the user releases the mouse, the picture will continueto jump. You should allow users to choose the jumping speed. Each time the jumping picture isclicked, it is switched to a different picture with soundarrow_forwardmultiplayer web based game——guess number (use socket.io, html, js) 3-player join the game with their name.Random number range from 1 to 100 will be show on the public screen.Players take turns entering numbers.The player who guesses the number will fail and be displayed on the public screen.arrow_forwardPicture card: Create a picture card that looks SIMILAR to this. There are images available in the "images" directory to assist you in making this card. They are not the same images, but there is an image of a desert and a person. Picture card In this screenshot, the title is "Title goes here", the secondary text is "Secondary text", and the body text is "Greyhound divisively hello coldly wonderfully marginally far upon excluding." The card's root element is a with a class of "card". The card is 344px wide. The desert picture is 194px tall. The padding between the body text and everything else is 16px. The color of the title text is #000. The color of the secondary and body texts is #232F34. The size of the person picture is 40px in diameter. The size of the body text is 11px. The size of the title is 22px. For the padding or margin around any other elements, use your best judgment to make it look like the screenshot.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,