Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 14, Problem 2SA
Program Plan Intro
Shape class:
- The basic functionality for drawing shapes is included in “Shape” class.
- A specific shape is been drawn by each of the subclasses in “Shape” class.
- The “Shape” class is present in JavaFX library.
- The lines are been drawn using “Line” class.
- The circles are been drawn using “Circle” class.
- The “Shape” class as well as its subclasses is present in “javafx.scene.shape” package.
- The JavaFX library holds “Shape” class that provides features for drawing shapes.
- The subclasses present in “Shape” includes:
- Line:
- It can draw a line from a point to another.
- Circle:
- It can draw a circle with a specific center as well as radius.
- Rectangle:
- It can draw a rectangle with specific height as well as width.
- Ellipse:
- It can draw an ellipse with a center point as well as radii.
- Arc:
- It draws an arc that denotes a partial ellipse.
- Polygon:
- It draws a polygon with vertices at particular locations.
- Polyline:
- It draws a polyline with vertices at particular locations.
- Text:
- It draws a string at a particular location.
- Line:
- The package used for “Shape” class as well as its subclasses is “javafx.scene.shape”.
Example:
The example for “Ellipse” class is given below:
Ellipse elp = new Ellipse(320, 240, 140, 100);
Here, “elp” denotes an object of “Ellipse” class. The given code generates an ellipse with given dimensions. The coordinates (140, 100) denotes X and Y coordinates respectively.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Calculating the area under a curve is a standard problem in numerical methods. What you will develop is an app that calculates and displays the area under a range of curves.
Figure 1: Area under the curve of y = x2 over the range 1 to 2, with 1 trapezoid.
The area can be calculated by drawing one or more polygons (trapezoids) that approximate the curve. We start by drawing a trapezoid that encompasses our curve between the given limits and the x-axis, so for equation 1 of table 1, it looks like figure 1. We then calculate the area of the trapezoid. Notice that the trapezoid over-estimates the true area. With enough (smaller) trapezoids we can get a very good approximation to the area under the curve (see figure 2). The sum of the area of the smaller trapezoids is the area under the curve.
The area of a trapezoid is given by: A = ½ (h1 + h2) d
Plot graphs of the equations in table 1 for varying (input) total numbers of trapezoids. Compute and display the area between each curve and…
Search a graphic method online and take a screenshot of it. Cite your reference.
Implement the "paint fill"feature seen in several picture editing products.To put it another way, if you have a screen (represented by a two-dimensional array of colours), a point, and a new colour, Fill in the surrounding area until the colour shifts away from the original.
Chapter 14 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 14.1 - Prob. 14.1CPCh. 14.1 - Prob. 14.2CPCh. 14.1 - Prob. 14.3CPCh. 14.1 - Prob. 14.4CPCh. 14.1 - In what package is the Color class?Ch. 14.1 - Prob. 14.6CPCh. 14.1 - Prob. 14.7CPCh. 14.1 - Prob. 14.8CPCh. 14.1 - Prob. 14.9CPCh. 14.1 - Prob. 14.10CP
Ch. 14.1 - Prob. 14.11CPCh. 14.1 - Prob. 14.12CPCh. 14.2 - Prob. 14.13CPCh. 14.2 - Prob. 14.14CPCh. 14.2 - Prob. 14.15CPCh. 14.2 - Prob. 14.16CPCh. 14.2 - Prob. 14.17CPCh. 14.2 - Prob. 14.18CPCh. 14.2 - Prob. 14.19CPCh. 14.2 - Prob. 14.20CPCh. 14.2 - Prob. 14.21CPCh. 14.3 - Prob. 14.22CPCh. 14.3 - Prob. 14.23CPCh. 14.3 - Prob. 14.24CPCh. 14.3 - Prob. 14.25CPCh. 14.3 - Prob. 14.26CPCh. 14.3 - Prob. 14.27CPCh. 14.3 - Prob. 14.28CPCh. 14.3 - Prob. 14.29CPCh. 14.3 - Prob. 14.30CPCh. 14.4 - What two classes do you use to play an audio file?Ch. 14.4 - Refer to your answer to Checkpoint 14.31. In what...Ch. 14.4 - Prob. 14.33CPCh. 14.4 - Prob. 14.34CPCh. 14.5 - What three classes do you use to play a video...Ch. 14.5 - Refer to your answer to Checkpoint 14.35. In what...Ch. 14.5 - Prob. 14.37CPCh. 14.6 - Prob. 14.38CPCh. 14.6 - Prob. 14.39CPCh. 14.6 - What type of event happens when the user presses...Ch. 14.6 - What KeyEvent method can you call to determine...Ch. 14.6 - Refer to your answer for Checkpoint 14.41. What...Ch. 14 - Line, Circle, and Rectangle are subclasses of...Ch. 14 - Prob. 2MCCh. 14 - Prob. 3MCCh. 14 - Prob. 4MCCh. 14 - Prob. 5MCCh. 14 - Prob. 6MCCh. 14 - Prob. 7MCCh. 14 - Prob. 8MCCh. 14 - This interpolator causes an animation to start...Ch. 14 - You use these two classes to play an audio file....Ch. 14 - Prob. 11TFCh. 14 - Prob. 12TFCh. 14 - True or False: If an ellipses X-radius and...Ch. 14 - Prob. 14TFCh. 14 - Prob. 15TFCh. 14 - Write a statement that instantiates the Line...Ch. 14 - Write a statement that instantiates the Circle...Ch. 14 - Prob. 3AWCh. 14 - Write code that does the following: Instantiates...Ch. 14 - Prob. 5AWCh. 14 - Write a statement that instantiates the Text...Ch. 14 - Prob. 7AWCh. 14 - Assume myBox is a Rectangle object. Write the code...Ch. 14 - Write code that creates a Circle, with a radius of...Ch. 14 - Prob. 10AWCh. 14 - Prob. 11AWCh. 14 - Prob. 1SACh. 14 - Prob. 2SACh. 14 - Prob. 3SACh. 14 - Prob. 4SACh. 14 - Prob. 5SACh. 14 - Prob. 6SACh. 14 - What RotateTransition class method do you use to...Ch. 14 - Prob. 8SACh. 14 - Prob. 9SACh. 14 - Prob. 10SACh. 14 - Prob. 11SACh. 14 - Prob. 1PCCh. 14 - Tree Age Counting the growth rings of a tree is a...Ch. 14 - Hollywood Star Make your own star on the Hollywood...Ch. 14 - Prob. 4PCCh. 14 - Solar System Use the Circle class to draw each of...Ch. 14 - Prob. 6PCCh. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Coin Toss Write a program that simulates the...Ch. 14 - Lunar Lander The books online resources...Ch. 14 - Change for a Dollar Game The books online...Ch. 14 - Rock, Paper, Scissors Game Write a program that...
Knowledge Booster
Similar questions
- This has 7 circles, can you do one with 10?arrow_forwardLook at the API of the Point class and find out how to construct a Point object. Write a Java program “PointTester”, that constructs two points with coordinates (3, 4) and (–3, –4). Find the distance between them, using the distance method. Print the distance, as well as the expected value. (You may draw a sketch on graph paper to find the value you will expect.) - Update your program so it randomly select coordinate points (x,y), where −50 ≤ ? ≤ 50 ??? ? ∈ [−90, 90].arrow_forwardWrite a method drawPentagon that draws a pentagon.arrow_forward
- Complete the recursive drawBoxes() method so that it will draw all of the boxes in the image below. It currently only draws the first and smallest Box. Feel free to use a different shape if you do not like boxes.arrow_forwardWhat is meant by Regular Expression? Why we used it? What is the difference between a regular expression and a descriptive method? Kindly give some examplesarrow_forwardJava I have a list of integers from 1 to 90, and I have 90 labels in scenebuilder. I want to give each label a value from that list. Is there a simple way to do this?arrow_forward
- Write a Rectangle class. Its constructor should accept length and width as a parameter. It should have methods that return its length, width, perimeter, and area. (Use Java) Show a demonstration where you create two separate rectangles.arrow_forwardTake your time with this. Programming language is Java.arrow_forwardFind a simple card game that you like and implement an interactive program to play that game. Some possibilities are war, blackjack, varioussolitaire games, and crazy eights.arrow_forward
- Suppose that a friend tells you a phone number that you need to dial, as soon as you are done talking. You don’t have a pencil, so you remember it by grouping it into two sections, one with three digits, and one with four digits. The method you have used is calledarrow_forwardThe obvious next step is to name the stars and planets using random numbers. Names usually follow certain rules rather than being made up of random strings of characters. Choose a set of real-world names (for example, from J.R.R. Tolkien's world) and create a set of rules for them to follow. Create and implement a method for generating new names based on a set of rules and random numbers.arrow_forwardRewrite Exercise 3.4 using the following func tion to return the area of a pentagon: def area(s):arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT