Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 18.39PE
Program Plan Intro
Drag the tree
Program Plan:
- Import required packages.
- Define the main class “E39” that extends the “Application” class.
- The method “start ()” overrides the start method in the “Application” class.
- Create a tree pane
- Create a text field.
- Set the depth.
- Set the value of the property using “setPrefColumnCount (4)”.
- Set the alignment to bottom right.
- Create a HBox pane
- Add the label and text field to the pane.
- Set the hbox alignment to center.
- Create a border pane
- Set the pane to the center location.
- Set the border pane at the bottom.
- Create a scene and place it on the stage.
- Display the stage using “show ()” method.
- Set the width and height.
- Declare a static class “TreePane” that extends Pane.
- Declare required variables.
- Give the constructor for this class.
- Set the mouse handler
- Call the function “paint ()”.
- Function definition to set depth of the tree.
- Set the depth and call the function “paint()”.
- Give function definition for “paint ()”.
- Clear the pane.
- Check the condition “(startX == 0 && startY == 0)”.
- Update the values.
- Paint the branch by calling the function “paint_Branch ()”.
- Give function definition for “paint_Branch ()”.
- Check if the depth is greater than 0.
- Calculate, create and add the line to the pane.
- Draw the left branch of the tree.
- Draw the right branch of the tree.
- Check if the depth is greater than 0.
- Declare a “main ()” function.
- Launch the application.
- The method “start ()” overrides the start method in the “Application” class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Draw the expression trees that represent the following expressions
fill in the blanks in the code
Explain the following code
Chapter 18 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 18.2 - What is a recursive method? What is an infinite...Ch. 18.2 - Prob. 18.2.2CPCh. 18.2 - Show the output of the following programs and...Ch. 18.2 - Prob. 18.2.4CPCh. 18.2 - Prob. 18.2.5CPCh. 18.2 - Write a recursive mathematical definition for...Ch. 18.3 - Prob. 18.3.1CPCh. 18.3 - What is wrong in the following methods?Ch. 18.3 - Prob. 18.3.3CPCh. 18.4 - Describe the characteristics of recursive methods.
Ch. 18.4 - Prob. 18.4.2CPCh. 18.4 - Prob. 18.4.3CPCh. 18.5 - Prob. 18.5.1CPCh. 18.5 - Prob. 18.5.2CPCh. 18.5 - What is a recursive helper method?Ch. 18.6 - Prob. 18.6.1CPCh. 18.6 - How does the program get all files and directories...Ch. 18.6 - How many times will the getSize method be invoked...Ch. 18.6 - Will the program work if the directory is empty...Ch. 18.6 - Will the program work if line 20 is replaced by...Ch. 18.6 - Will the program work if lines 20 and 21 are...Ch. 18.7 - Prob. 18.7.1CPCh. 18.8 - Prob. 18.8.1CPCh. 18.8 - Prob. 18.8.2CPCh. 18.8 - How many times is the displayTriangles method...Ch. 18.8 - Prob. 18.8.4CPCh. 18.8 - Prob. 18.8.5CPCh. 18.9 - Which of the following statements are true? a. Any...Ch. 18.9 - Prob. 18.9.2CPCh. 18.10 - Identify tail-recursive methods in this chapter.Ch. 18.10 - Rewrite the fib method in Listing 18.2 using tail...Ch. 18 - Prob. 18.1PECh. 18 - Prob. 18.2PECh. 18 - (Compute greatest common divisor using recursion)...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Fibonacci series) Modify Listing 18.2,...Ch. 18 - Prob. 18.8PECh. 18 - (Print the characters in a string reversely) Write...Ch. 18 - (Occurrences of a specified character in a string)...Ch. 18 - Prob. 18.11PECh. 18 - (Print the characters in a string reversely)...Ch. 18 - (Find the largest number in an array) Write a...Ch. 18 - (Find the number of uppercase letters in a string)...Ch. 18 - Prob. 18.15PECh. 18 - (Find the number of uppercase letters in an array)...Ch. 18 - (Occurrences of a specified character in an array)...Ch. 18 - (Tower of Hanoi) Modify Listing 18.8,...Ch. 18 - Prob. 18.19PECh. 18 - (Display circles) Write a Java program that...Ch. 18 - (Decimal to binary) Write a recursive method that...Ch. 18 - (Decimal to hex) Write a recursive method that...Ch. 18 - (Binary to decimal) Write a recursive method that...Ch. 18 - (Hex to decimal) Write a recursive method that...Ch. 18 - Prob. 18.25PECh. 18 - (Create a maze) Write a program that will find a...Ch. 18 - (Koch snowflake fractal) The text presented the...Ch. 18 - (Nonrecursive directory size) Rewrite Listing...Ch. 18 - (Number of files in a directory) Write a program...Ch. 18 - (Game: Knights Tour) The Knights Tour is an...Ch. 18 - (Game: Knights Tour animation) Write a program for...Ch. 18 - (Game: Eight Queens) The Eight Queens problem is...Ch. 18 - Prob. 18.35PECh. 18 - (Sierpinski triangle) Write a program that lets...Ch. 18 - (Hilbert curve) The Hilbert curve, first described...Ch. 18 - (Recursive tree) Write a program to display a...Ch. 18 - Prob. 18.39PE
Knowledge Booster
Similar questions
- Answer the following question in R and show the code.arrow_forwardWhat are three things you may do if you've completed the debugging procedure but are still unable to resolve the issue?arrow_forwardExplain three things you may do if you've completed the debugging technique but are still unable to resolve the issue.arrow_forward
- CODE USING C++ 2. I'm Lost, Help! by CodeChum Admin Thanks for your help previously, Programmer. I'm now on my to the enemy's base but it seems that I'm lost. I've been going on for quite some time now and it seems that things are always the same. Can you help me fix this map I am holding? Instructions: In the code editor, you are provided with an initial main() code and an initial walk() recursive function. The walk() recursive function is basically printing the values from 1 to 1000. However, currently, the walk() function is broken - it's always printing 1. It seems that there's something wrong with its recursive case. Try to fix it so Agent J. will find his way to the enemy's base. Output 1 2 3 4 5 6 7 8 9 10 . . .arrow_forwardIs this code right or am I missing something ?arrow_forwardPython Programming:- thislist = ["apple", "banana", "melon", "cherry", "orange", "kiwi", "mango"] # Using the given list above, write a quick python script that## a. First, outputs only the FIRST 3 elements from the list# b. Second, outputs the LAST 3 elements from the list# c. Third, outputs ONLY the elements whose first letter is "m"# d. Last, outputs ONLY the last element from the listarrow_forward
- What are three things you might do if you have completed the debugging procedure but are still unable to resolve the issue?arrow_forwardSolve the questions on recursive function; please refer to the screenshot;arrow_forwardFibonacci write 4 function (Recursion version, Memoization version) (Iterative version, Tabulation version) and main function to test the 4 functions ,, by c++.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr