Question
Book Icon
Chapter 29, Problem 29.12PE
Program Plan Intro

Display weighted graphs

Program Plan:

  • Create a package “main”.
    • Add a java class named “Edge” to the package which is used to get the edges from the graph.
    • Add a java class named “Graph” to the package which is used to add and remove vertices, edges.
    • Add a java class named “UnweightedGraph” to the package which is used to store vertices and neighbors.
    • Add a java class named “WeightedGraph” to the package which is used to get the weighted edges and print the edges.
    • Add a java class named “WeightedEdge” to the package which is used to compare edges.
    • Add a java class name “Displayable” to the package.
      • Declare the functions “get_X ()”, “get_Y ()”, “get_Name ()”.
    • Add a java class named “E12” to the package.
      • Declare the cities.
      • Declare an integer array.
      • Create an object for the weighted graph.
      • Create a graphview pane.
      • Declare “start ()” method that overrides the “start ()” method in the “Application” class.
        • Create a scene and place it on the stage.
        • Display the stage.
      • Declare the class “GraphView”.
        • The “Graph” class extends the interface “Displayable”.
        • Give the constructor for this class.
          • Set the graph and call the function “paint ()”.
        • Give function definition for “paint ()”.
          • Declare a list that extends Displayable.
          • Loop from 0 through size.
            • Get the vertices.
            • Get the name of the city.
            • Add the circle, text and vertices to the pane.
          • Loop from 0 through graph size.
            • Create a list.
            • Loop from 0 through neighbor’s size.
              • Get the vertices.
              • Inside the “try” block,
                • Add the line, text and vertices to the pane.
              • Inside the “catch” block,
                • Throw the exception.
      • Declare a class named “Cities”.
        • Declare required variables.
        • Give the constructor for this class which sets the name of the city, and the vertices.
        • Get and return the co-ordinate of the vertex “x”.
        • Get and return the co-ordinate of the vertex “y”.
        • Get and return the name of the city.
        • Declare function to compare cities.
          • Return the value.
      • Give the “main ()” method.
        • Launch the application.

Blurred answer
Students have asked these similar questions
Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…
make a screen capture showing the StegExpose results
Which of the following is not one of the recommended criteria for strategic objectives? Multiple Choice   a) realistic   b) appropriate   c) sustainable   d) measurable
Knowledge Booster
Background pattern image
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,