Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 28, Problem 28.21PE
Program Plan Intro

Display set of connected circle

Program Plan:

Exercise.java:

  • Import the required packages.
  • Create a class “Exercise”:
    • New circle gets created.
    • Define the start method:
      • New scene is created.
      • Set the title of the stage.
      • Scene gets placed on the stage.
      • Scene gets displayed.
    • Define the main method
      • Initialize the calls.
    • Define the class “MycirclePane”
      • Declare the required variables.
      • Set the color index
      • Validate the mouse event that is performed.
    • Define the method “isInsideAnyCircle”
      • Loop that iterates to validate the circle contains x and y position.
      • Return true or false after validation.
    • Define the method “repaint”
      • Pane gets cleared.
      • Condition to validate the circle size gets defined.
      • Loop that iterates to build the edge is defined.
      • New graph gets created.
      • Components that need to connect are defined.
      • Loop that iterates to validate the circle and add components to it gets defined.
    • Define the method overlaps
      • Return the position.

Mygraph.java:

  • Define and create the class “MyGraph”
    • Create a new constructor.
    • New graph gets using the constructor.
    • Method to find “getConnectedComponents()” gets created.
      • New list gets created.
      • Loop that iterates to add the vertices into the list.
      • Loop that iterates to add the neighbor vertices into the list.
      • Loop that iterates to perform a depth first search.
      • Add the values to the list.
      • Remove all the values from the list.
      • Finally return the list.

UnweightedGraph.java:

  • Import the required packages.
  • Create a class “UnweightedGraph”:
    • New list for the vertices gets created.
    • New list for the neighbor node gets created.
    • Create an empty constructor.
    • Method to create new graph gets created and adjacency list gets created.
    • Method to create an adjacency list gets created.
    • Method to return the size of the vertices.
    • Method to return the index of the vertices gets defined.
    • Method to gets the neighbor node gets defined.
    • Method to return the degree of the vertices gets created.
    • Method to print the Edges gets created.
    • New to clear the graph gets created.
    • Method to add vertex gets created.
    • Method to add edge gets created.
    • Method to perform the depth first search gets defined.
    • Method to perform breadth first search gets defined.
      • Search tree gets returned.
  • Create a class “SearchTree”
    • Define the method to return the root.
    • Method to return the parent of the vertices
    • Method to return the search order gets defined.
    • Method to return the number of vertices found gets defined.
    • Method to get the path of the vertices gets defined.
      • Loop to validate the path gets defined.
      • Path gets returned.
    • Method to print the path gets defined.
    • Method to print the tree gets defined.
      • Display the edge.
      • Display the root.
      • Condition to validate the parent node to display the vertices gets created.

Graph.java:

  • A graph interface gets created.
  • Method to return the size gets defined.
  • Method to return the vertices gets defined.
  • Method to return the index gets created.
  • Method to get the neighbor node gets created.
  • Method to get the degree gets created.
  • Method to print the edges.
  • Method to clear the node gets created.
  • Method to add the edges, add vertex gets created.
  • Method to remove the vertices gets defined.
  • Method for the depth first search gets defined.
  • Method for the breadth first search gets defined.

Edge.java

  • Create a class “Edge”
    • Define and declare the required variables.
    • Constructor gets defined.
    • Method that defines Boolean objects gets defined.
      • Return the value after validating the vertices.

Blurred answer
Students have asked these similar questions
(€) 10:08 ••. 4. Random walkers. Write a program RandomWalkers.java that takes two integer command-line arguments r and trials. In each of trials independent experiments, simulate a random walk until the random walker is at Manhattan distance r from the starting point. Print the average number of steps. -/Desktop/loops> java Randomwalkers 5 1000000 average number of steps = 14.98188 -/Desktop/loops> java Randomlalkers 5 1000000 average number of steps = 14.93918 -/Desktop/loops> java Randomlalkers 10 100000 average number of steps = 59.37386 -/Desktop/loops> java Randomlalkers 20 100000 average number of steps = 235.6288 -/Desktop/loops> java Randomwalkers 40 100000 average number of steps = 949.14712 -/Desktop/loops> java Randomwalkers 80 100000 average number of steps = 3775.7152 -/Desktop/loops> java Randomwalkers 160 100000 average number of steps = 15113.61108 As r increases, we expect the random walker to take more and more steps. But how many more steps? Use RandomWalkers.java…
(Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are both emirps. Write a Java program that displays the first 100 emirps. Display 10 numbers per line with a spacing of 5; all numbers should be left-aligned.
(CLO3) Read the following description and answer the following questions about it: Problem Description: A car dealership allows customer to purchase their new cars with different options. At this time, those options are color, model, and air condition, as shown below in class CustomerOrder. Of course, the dealership wants the software to be flexible enough to be able to add more options in the future, if needed. CustomerOrder -carColor: String -carModel: String -hasAirCondition: boolean Q1) Write the full required code in Java to use the Builder design pattern to create class CustomerOrder. Q2) Write a Java main() method to create an object of class CustomerOrder with color "red" and without air condition.

Chapter 28 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License