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
Expert Solution & Answer
Chapter 14, Problem 3AW
Explanation of Solution
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 “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...
- Line:
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write code to declare and create a Random class object (use the rand object reference variable). Then, using the nextInt method, create a list of expressions that produce random numbers in the following ranges, including the end points. Use the nextInt method's iteration that only takes an integer input.a. 0 to 10
b. 0 to 500c. 1 to 10d. 1 to 500e. 25 to 50f. -10 to 15
Write code to declare and create a Random class object (use the rand object reference variable). Then, using the nextInt method, create a list of expressions that produce random numbers in the following ranges, including the end points. Use the nextInt method's iteration that only takes an integer input.a. 0 to 10
b. 0 to 500c. 1 to 10d. 1 to 500e. 25 to 50f. -10 to 15
Create two enumerations that hold colors and car modeltypes. You will use them as field types in a Car class and write ademonstration program that shows how the enumerations are used.
Please help with the below using java. Include getters and setters and comment where they are on the code. Please also comment the whole code
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
- Complete the code in the Practice class such that each time the user clicks the SUM button, the sum of the two valid integers will be shown in the lower right corner of the window (leave the user's input in the text fields). Here is a before and after view of the graphical user interface when the SUM button is clicked for the first time. 123 456 123 456 SUM SUM 579 import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Practice { public static void main(String[] args) { JFrame frame = new JFrame("Add 2"); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); SumPanel panel = new SumPanel(); frame.getContentPane().add(panel); frame.setSize(140,80); frame.setVisible(true); } } class SumPanel extends JPanel { private JTextField op1Field; private JTextField op2Field; private JButton sumButton; private JLabel sumLabel; public SumPanel() { //Step 1; set up the layout setLayout(new GridLayout(2,2,4,4)); op1Field = new JTextField(); op2Field = new JTextField();…arrow_forwardOverview You need to implement three programs: Area, Divisible, and ColorGenerator. SpecificationsYou need to implement four programs: Perimeter, EvenNumber, FormulaEval, and PickColor. For this project you are expected to use good variable names and good indentation. Area Program - Write a program that will compute the area of a rectangle. The program willread the length and width values and display the perimeter. The following is an example ofrunning the program. The example illustrates the messages used to read data and to displaythe area. Enter base: 7 Enter height: 5 Area is: 17.5. ColorGenerator Program - Write a program that computes a CSS color. We define a CSScolor as a string that starts with a # character and it is followed by three pairs of 2 characters.The possible pairs of two characters will be 00 or FF. A color is defined by two characters forred, two characters for green, and two characters for blue. For example, #FF0000 is…arrow_forwardComplete the following code as instructed in the line comments. String title = "Dame" name = "Liz taylor", citizenship = "British American"; //Create a StringBuilder object called correctName and send it name. //Capitalize the 't' in "taylor". //Replace "Liz" with "Elizabeth". //Append a comma followed by a space to the object. //Append "you were a famous actress." to the object. //Print the object using an explicit call to toString (). //Use the stringBuilder object to call its toString () explicitly, then call split() to tokenize the String version of the StringBuilder object into an array called message. Use a space as the delimiter or separator. This is all one Java statement. //Code the header for an enhanced for to print the tokens from the message array. The variable to hold each token is called word. { System.out. ("%n%s", ); //Fill-in the correct method to print. Fill-in the correct argument. }//END enhanced forarrow_forward
- Create a constructor for the Student class you created. The constructor should initialize each Student’s ID number to 9999, his or her points earned to 12, and credit hours to 3 (resulting in a grade point average of 4.0). Write a program that demonstrates that the constructor works by instantiating an object and displaying the initial values. Save the application as ShowStudent2.java.arrow_forwardQ#2: Create a class named “Rectangle” having length and width as attribute. There should be behaviors to set the values of length and width (individually and collectively), and get their values individually. There should also behavior to display the perimeters and area of the rectangle. Create another class named as Main which have two objects of Rectangle (r1, r2) having length (3.2, 20) and width (4.5, 36) respectively. Also display the length, width, perimeter and area of both rectangles.arrow_forwardCreate the VisualCounter class, which supports both increment and decrement operations. Take the constructor's two arguments N and max, where N indicates the maximum operation number and max specifies the counter's maximum absolute value. Make a plot that displays the value of the counter each time its tally changes as a byproduct.arrow_forward
- Click the four endpoints of the rectangles in the given java statement. 1. g.drawRect(150, 200, 400, 50);arrow_forward2. The following graphic shows the number of students in each class. Write code that shows the given graphic. Number of the students who are taking the classes are 20, 30, 30, 10, 5, 5 for General Chemistry, General Physics, Mathematics, Mass Transfer, Fluid Mechanics, Thermodynamics, respectively. The graphic does not have to be as exactly as shown. Different codes, colours and modules can be used. Classes General Physics Mathematics General Chemistry Thermodynamics Fluid Mechanics Mass Transferarrow_forwardFor your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every…arrow_forward
- Sammy's Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists. In Chapter 3, you created a Rental class for the company. The Rental class contains two public final static fields that hold the number of minutes in an hour and the hourly rental rate ($40), and four private fields that hold a contract number, number of hours for the rental, number of minutes over an hour, and the price. It also contains two public set methods and four public get methods. Now, modify the Rental class to contain two overloaded constructors. One constructor accepts a contract number and number of minutes as parameters. Pass these values to the setContractNumber() and setHoursAndMinutes() methods, respectively. The setHoursAndMinutes() method will automatically calculate the hours, extra minutes, and price. The other constructor is a default constructor that passes "A000" and 0 to the two-parameter constructor. Save the file as Rental.java. b. In Chapter…arrow_forwardEverything is in the attached picture! Thank you so much!arrow_forwardThe dealership sells different types of vehicles: cars and trucks. All vehicles have a make, model, and year. However, a truck has an additional attribute - maximum load capacity (in pounds). Create a class named Vehicle with the following attributes: make, model, and year. Include the following methods: display_info(): This method should print all these details in a formatted string. get_age(): This method should calculate and return the age of the vehicle based on the current year. Tip: You will need to import functionality from the datetime module to do this. Create a class named Truck that inherits from the Vehicle class. This class should have an additional attribute, max_load, which represents the maximum load capacity of the truck. Include the following methods: display_info(): This method should override the method from Vehicle, and when it's called, it should display the truck's make, model, year, and maximum load capacity. can_carry(weight): This method should take a…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage