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

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

Remove a 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 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 “colorIfconnected”
      • Condition to validate the number of circle present.
      • Loop that iterates to add the circle.
      • New graph gets created.
      • Perform a depth first search.
      • Add the circles.
      • Set the fill color and stroke color for the circles added.
    • Define the method “overlaps”
      • Return the position.
    • Define the main method
      • Initialize the calls.

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
(Intro to Java) Open a new Java file called ArrayMethods.java. Read the Javadoc comment for each method below and write the method according to the description in the comment Once you are getting the correct output for all tests inside of main, upload your source file to Canvas public class ArrayMethods {    /**     * Displays the contents of an array on the console     * with each element separated by a blank space     * Prints a new line character last     * @param nums the array to print to the console     */    public static void printArray(int[] nums) {        return;    }        /**    * Assuming an array of integers, return true if 1    * is the first element or 1 is the last element    * Note: you may assume that you will be given an array    * of at least length 1    * is1FirstLast([1, 2, 10]) → true    * is1FirstLast([10, 1, 2, 1]) → true    * is1FirstLast([13, 10, 1, 2, 3]) → false    * @param numbers the array of int numbers    * @return whether or not 1 is the first or…
(Rectangle Class) Create a class Rectangle with attributes lengthand width, each of which defaults to 1. Provide methods that calculatethe rectangle’s perimeter and area. It has set and get methods for bothlength and width. The set methods should verify that length andwidth are each floating-point numbers larger than 0.0 and less than 20.0.Write a program to test class Rectangle.(Java Programming Language)
(Geometry: MyRectangle2D class)  Define the  MyRectangle2D class that contains:  Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to the x- or y-axis.) The data fields width and height with getter and setter methods. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A Constructor that creates a rectangle with the specified x, y, width, and height. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a ). A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b ). A method overlaps(MyRectangle2D r) that returns true if the specified rectangle overlaps with this…

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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning