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
Concept explainers
Question
Chapter 16.12, Problem 16.12.1CP
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
You are hired by a game design company and one of their most popular games is
The Journey. The game has a ton of quests, and for a player to win, the player must finish all the quests.
There are a total of N quests in the game. Here is how the game works: the player
can arbitrarily pick one of the N quests to start from. Once the player completes a quest, they unlock some other quests. The player can then choose one of the unlocked quests and complete it, and so on.
For instance, let’s say that this game had only 4 quests: A, B, C, and D. Let’s say that after you complete
• quest A, you unlock quests [B, D].
• quest B, you unlock quests [C, D].
• quest C, you unlock nothing [ ].
• quest D, you unlock quest [C].
Is this game winnable? Yes, because of the following scenario:
The player picks quest A to start with. At the end of the quest A, the unlocked list
contains [B, D]. Say that player chooses to do quest B, then the…
Description:
Raghu and Sayan both like to eat (a lot) but since they are also looking after their health, they can only eat
a limited amount of calories per day. So when Kuldeep invites them to a party, both Raghu and Sayan
decide to play a game. The game is simple, both Raghu and Sayan will eat the dishes served at the party
till they are full, and the one who eats maximum number of distinct dishes is the winner. However, both
of them can only eat a dishes if they can finish it completely i.e. if Raghu can eat only 50 kCal in a day
and has already eaten dishes worth 40 kCal, then he can't eat a dish with calorie value greater than 10
kCal.
Given that all the dishes served at the party are infinite in number, (Kuldeep doesn't want any of his
friends to miss on any dish) represented by their calorie value(in kCal) and the amount of kCal Raghu and
Sayan can eat in a day, your job is to find out who'll win, in case of a tie print "Tie" (quotes for clarity).
Input:
First line contains…
In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the numberof points to risk and a second prompt asks the player to choose either high or low. The player rollstwo dice and the outcome is compared to the player’s choice of high or low. If the dice total is between2 and 6 inclusive, then it is considered “low”. A total between 8 and 12 inclusive is “high”. A total of7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, thepoints at risk are doubled and added to the total points. For a wrong call, the player loses the points atrisk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. TheDRPlayer object should have two Die member variables that represent the dice. The Die class shoulduse a random number generator to determine the outcome in a roll() method. Application outputshould look similar to:
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the numberof points to risk and a second prompt asks the player to choose either high or low. The player rollstwo dice and the outcome is compared to the player’s choice of high or low. If the dice total is between2 and 6 inclusive, then it is considered “low”. A total between 8 and 12 inclusive is “high”. A total of7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, thepoints at risk are doubled and added to the total points. For a wrong call, the player loses the points atrisk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. TheDRPlayer object should have two Die member variables that represent the dice. The Die class shoulduse a random number generator to determine the outcome in a roll() method. Application outputshould look similar to:arrow_forwardRaccoon Rhapsody is a quest-based game. People who sign up for Raccoon Rhapsody — call them players — have accounts. For each player's account, we keep track of the player's name, address, the date that they joined, a cc# (a valid credit card number we keep on file), and a balance (how much money in Canadian dollars they presently have in their game account). Each player will also have a unique login, which is the account's “name”. It is assumed that a given player will have just one account. A player may create over time any number of avatars. An avatar is an in-game persona. Thus, an avatar belongs to a player (an account). An avatar has a name, gender, look, and skill level. There is a small set of looks available, which may be extended over time; e.g., “wizard”, “faerie”, “footballer”, “shark”, and “raccoon”. The game's virtual word is divided up into a number of realms. On any given day, a player may log in (visit) as one of his or her avatars into one of the realms. (The player…arrow_forwardplease create a class diagram for the 2048 game can you please draw the diagramarrow_forward
- Correct answer will be upvoted else downvoted. speed up development the game has n quick travel towers. I-th tower is situated at area (xai,yai). To have the option to quickly venture out to the pinnacle from any area in the game world it should initially be actuated. Initiation of pinnacle I occurs right when the player is in cell (xai,yai) after this the pinnacle stays dynamic all through the whole game. William additionally realizes that the game has m missions. I-th journey can be finished immediately by being at area (xbi,ybi) on turn ti. William needs to discover the maximal number of missions he will actually want to finish by ideally navigating the game world. Input :The main line contains two integers n and m (0≤n≤14,1≤m≤100), which are the number of pinnacles and the number of journeys, individually. Every one of the following n lines contains two integers xai,yai (1≤xai,yai≤106), which are the directions of quick travel towers. Every one of the following m…arrow_forwardDescription: The game is a single player scenario, in which the player’s army needs to defeat the enemy’s (AI’s) army. There are 4 possible troops for an army: Archers, Spearman, Cavaliers, Footman. Each troop has some attributes and some actions. And to avoid excessive programming and calculation, we want to treat these troops as squadrons. The player always starts with 10 squadrons of their choices: they can choose any combinations of the 4 possible troop types. Each squadron should have 100 members of that troop type. Each turn, the player is allowed to choose one of their squadrons and perform an action which is allowed by that troop type. Player and the AI take turns to make actions. The game continues until either the player or the AI has no troops left. Troop Types and Descriptions: Archers: should be able to attack from range with no casualties, meaning the attack action should not cause any damage to themselves. They should be pretty fragile to anything themselves. They…arrow_forwardSuppose you have been hired to develop a musical chair game. In this game there will be 7participants and all of them will be moving clockwise around a set of 7 chairs organized in a circular manner while a music will be played in the background. You will control the music using random numbers between 0-3.If the generated random number is 1, you will stop the music and if the number of participants who are still in the game is n, theparticipant at position (n/2) will be eliminated. Each time a participant is eliminated, a chair will be removed and you have to print the player names who are still in the game. The game will end when there will be only one participant left. At the end of the game, display the name of the winner.[Hint: You will need to invoke a method to generate a random number between 0(inclusive) to 3 (inclusive)]write code in java or pythonarrow_forward
- The fields timesGet and timesAvoid should each influence either the score, or the game-over condition, or both. For example, maybe getting something good increases the score, hitting something bad decreases the score, and the game ends after a set amount of time. Or alternatively, maybe getting something good increases the score, and hitting a certain number of bad things ends the game. Or alternatively, maybe the score depends only on how long the user has stayed alive, and the user dies when they've hit more bad things than good things. There are many possibilities here. Complete the getScore method, which should return the current game score. In determining the score, you may use timesGet, timesAvoid, and msElapsed. Then modify updateTitle to show the title of your game. (You're welcome to show other statistics in the title, in addition to the score.) Test that the score now updates correctly, as you play your game and collide with images.arrow_forwardOthello is played as follows: Each Othello piece is white on one side and black on the other. When a piece is surrounded by its opponents on both the left and right sides, or both the top and bottom, it is said to be captured and its color is flipped. On your turn, you must capture at least one of your opponent's pieces. The game ends when either user has no more valid moves. The win is assigned to the person with the most pieces. Implement the object-oriented design for Othello.arrow_forwardThis is related to Dungeons and Dragons: Your character has just been reduced to 0 Hit Points (HP) (because of a fireball) and is now dying. They must now make several Death Saving Throws to determine their fate. Death saving throws are rolled every turn until you get three successes or three failures. To make a death saving throw, simply roll a d20. If the roll is 10 or higher, you succeed. Otherwise, you fail. On your third success, you become stable. On your third failure, you die. If you roll a 1, it counts as two failures. If you roll a 20, you regain 1 hit point. In which case, you regain consciousness and can fight once more! Calculate the probability that your character dies.arrow_forward
- Email me the answers to the following questions. If you are not familiar with Peg Solitaire, then look it up online. Peg Solitaire is a game consisting of a playing board with 33 holes together with 32 pegs. In the picture above, the hole in the center is empty and the remaining holes contain pegs. The goal is to remove all the pieces except one, which should be in the center. A piece can be removed by jumping an adjacent piece over it into an empty hole. Jumps are permitted horizontally or vertically, but not diagonally. Your assignment consists of one required part, plus one extra credit part: 1. Explain (in words) why Breadth First Search and Iterative Deepening are not good methods for this problem.arrow_forwardCreate a Minesweeper game that is text-based. Minesweeper is a classic single-player computer game in which a NxN grid contains B mines (or bombs) hidden throughout. The remaining cells are either blank or contain a number. The numbers represent the number of bombs in the eight surrounding cells. The user then finds a cell. If it's a bomb, the player is out.If it is a number, it is displayed. If it is a blank cell, it is exposed, as are all adjacent blank cells (up to and including the surrounding numeric cells). When all non-bomb cells are exposed, the player wins. The player can also mark specific locations as potential bombs.This doesn't affect gameplay, other than to block the user from accidentally clicking a cell that is thought to have a bomb.(Tip for the reader: if you're not familiar with this game, please play a few rounds on line first.)arrow_forwardA video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return . Example The character can jump unit high initially and must take doses of potion to be able to jump all of the hurdles. Function Description Complete the hurdleRace function in the editor below. hurdleRace has the following parameter(s): int k: the height the character can jump naturally int height[n]: the heights of each hurdle Returns int: the minimum number of doses required, always or more Input Format The first line contains two space-separated integers and , the number of hurdles and the maximum height the character can jump naturally.The…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Time Complexity Analysis - How To Calculate Running Time | InterviewBit; Author: InterviewBit;https://www.youtube.com/watch?v=--oxG4Q1PA0;License: Standard YouTube License, CC-BY