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 28.5, Problem 28.5.2CP
Program Plan Intro
Given scenario:
The object “graph1” is created for “GraphView” class in “TestGraph.java” is as follows:
GraphView view=new GraphView(graph1);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
in this android app
package com.example.myapplication;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.widget.ListView;public class PlayerActivity2 extends AppCompatActivity {ListView simpleList;String SerialNo[] = {"1", "2", "3", "4", "5", "6","7","8","9","10"};int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10};String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd","eee jk"," ijk","Virgil jk","gil jklk"};String Score[] = {"1", "2","3", "5", "4", "3","5","5","5","5"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity2);simpleList = (ListView)findViewById(R.id.simpleListView);//ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.activity_listview, R.id.textView,…
import bridges.base.ColorGrid;import bridges.base.Color;public class Scene {/* Creates a Scene with a maximum capacity of Marks andwith a background color.maxMarks: the maximum capacity of MarksbackgroundColor: the background color of this Scene*/public Scene(int maxMarks, Color backgroundColor) {}// returns true if the Scene has no room for additional Marksprivate boolean isFull() {return false;}/* Adds a Mark to this Scene. When drawn, the Markwill appear on top of the background and previously added Marksm: the Mark to add*/public void addMark(Mark m) {if (isFull()) throw new IllegalStateException("No room to add more Marks");}/*Helper method: deletes the Mark at an index.If no Marks have been previously deleted, the methoddeletes the ith Mark that was added (0 based).i: the index*/protected void deleteMark(int i) {}/*Deletes all Marks from this Scene thathave a given Colorc: the Color*/public void deleteMarksByColor(Color c) {}/* draws the Marks in this Scene over a background…
Using comments within the code itself, can you provide an line by line explanation of the below JavaScript file? The file itself deals with WebGl and if that helps you.
Please and thank you
JavaScript file:
function MVbuffer(size) {
var b = {};
b.buf = new Float32Array(size);
b.index = 0;
b.push = function(x) {
for(var i=0; i<x.length; i++) {
b.buf[b.index+i] = x[i];
}
b.index += x.length;
b.type = '';
}
return b;
}
function isVector(v) {
if(v.type == "vec2" || v.type == "vec3" || v.type == "vec4") return true;
return false;
}
function isMatrix(v) {
if(v.type == "mat2" || v.type == "mat3" || v.type == "mat4") return true;
return false;
}
function radians( degrees ) {
return degrees * Math.PI / 180.0;
}
//----------------------------------------------------------------------------
function patch() {
var out = new Array(4);
for(var i = 0; i< 4; i++) out[i] = new Array(4);
out.type = "patch";
return out;
}
function curve() {
var out = new Array(4);
out.type = "curve";…
Chapter 28 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 28.2 - What is the famous Seven Bridges of Knigsberg...Ch. 28.2 - Prob. 28.2.2CPCh. 28.2 - Prob. 28.2.3CPCh. 28.2 - Prob. 28.2.4CPCh. 28.3 - Prob. 28.3.1CPCh. 28.3 - Prob. 28.3.2CPCh. 28.4 - Prob. 28.4.1CPCh. 28.4 - Prob. 28.4.2CPCh. 28.4 - Show the output of the following code: public...Ch. 28.4 - Prob. 28.4.4CP
Ch. 28.5 - Prob. 28.5.2CPCh. 28.6 - Prob. 28.6.1CPCh. 28.6 - Prob. 28.6.2CPCh. 28.7 - Prob. 28.7.1CPCh. 28.7 - Prob. 28.7.2CPCh. 28.7 - Prob. 28.7.3CPCh. 28.7 - Prob. 28.7.4CPCh. 28.7 - Prob. 28.7.5CPCh. 28.8 - Prob. 28.8.1CPCh. 28.8 - When you click the mouse inside a circle, does the...Ch. 28.8 - Prob. 28.8.3CPCh. 28.9 - Prob. 28.9.1CPCh. 28.9 - Prob. 28.9.2CPCh. 28.9 - Prob. 28.9.3CPCh. 28.9 - Prob. 28.9.4CPCh. 28.10 - Prob. 28.10.1CPCh. 28.10 - Prob. 28.10.2CPCh. 28.10 - Prob. 28.10.3CPCh. 28.10 - If lines 26 and 27 are swapped in Listing 28.13,...Ch. 28 - Prob. 28.1PECh. 28 - (Create a file for a graph) Modify Listing 28.2,...Ch. 28 - Prob. 28.3PECh. 28 - Prob. 28.4PECh. 28 - (Detect cycles) Define a new class named...Ch. 28 - Prob. 28.7PECh. 28 - Prob. 28.8PECh. 28 - Prob. 28.9PECh. 28 - Prob. 28.10PECh. 28 - (Revise Listing 28.14, NineTail.java) The program...Ch. 28 - (Variation of the nine tails problem) In the nine...Ch. 28 - (4 4 16 tails problem) Listing 28.14,...Ch. 28 - (4 4 16 tails analysis) The nine tails problem in...Ch. 28 - (4 4 16 tails GUI) Rewrite Programming Exercise...Ch. 28 - Prob. 28.16PECh. 28 - Prob. 28.17PECh. 28 - Prob. 28.19PECh. 28 - (Display a graph) Write a program that reads a...Ch. 28 - Prob. 28.21PECh. 28 - Prob. 28.22PECh. 28 - (Connected rectangles) Listing 28.10,...Ch. 28 - Prob. 28.24PECh. 28 - (Implement remove(V v)) Modify Listing 28.4,...Ch. 28 - (Implement remove(int u, int v)) Modify Listing...
Knowledge Booster
Similar questions
- Customer This class should now implement the Comparable interface. Customer instances should be ordered by their last name, then first name, and finally the name of their associated building. toString() - Add this method that returns a String with the following format: <lastName>, <firstName> Reading This class should now implement the Comparable interface. Reading instances should be ordered by their timestamp. XmlHandler The following methods should be updated: startElement() - The handler logic should be modified such that it can now create and associate Customer, Building, Room, Device, and Reading objects. endElement() - Modify this method such that the current customer instance is added to the ArrayList of customers when a closing customer element is encountered. No hand written and fast answer pleasearrow_forwardUsing comments within the code itself, can you provide an line by line explanation of the below JavaScript file? The file itself deals with WebGl and if that helps you. Please & thank you JavaScript File: function inverse2(m) { var a = mat2(); var d = det2(m); a[0][0] = m[1][1]/d; a[0][1] = -m[0][1]/d; a[1][0] = -m[1][0]/d; a[1][1] = m[0][0]/d; return a; } function inverse3(m) { var a = mat3(); var d = det3(m); var a00 = [ vec2(m[1][1], m[1][2]), vec2(m[2][1], m[2][2]) ]; var a01 = [ vec2(m[1][0], m[1][2]), vec2(m[2][0], m[2][2]) ]; var a02 = [ vec2(m[1][0], m[1][1]), vec2(m[2][0], m[2][1]) ]; var a10 = [ vec2(m[0][1], m[0][2]), vec2(m[2][1], m[2][2]) ]; var a11 = [ vec2(m[0][0], m[0][2]), vec2(m[2][0], m[2][2]) ]; var a12 = [ vec2(m[0][0], m[0][1]), vec2(m[2][0], m[2][1]) ]; var a20 = […arrow_forwardThe first image is the main question and the second image is the directions for the program. The program has to be written in Java and please use the directions given in the second image to write the program.arrow_forward
- Computer Science Write the client code to show how you make use of the LegacyCircle class with your new design.arrow_forwardFor this task, you need to develop a JavaFX application in NetBeans that implements a LinkedHashMap class. The Java application should consist of a graphical user interface that can be used to add elements to the LinkedHashMap. There should be two TextFields to take in the element name and number. Then there should be four buttons to do four tasks, namely: add, change, remove and show all elements in the LinkedHashMap. Your buttons should have Action methods and should make use of methods in the LinkedHashMap class.When the Add button is clicked, the element name and value should be added to the LinkedHashMap. Make use of the LinkedHashMap methods to add the elements. When the user fills in the element name and number and the Add button is clicked, a message should be displayed in an alert dialog box to the user to inform them of this If no element is specified at the time the Add button is clicked, an error message should be displayed to inform the user to enter the elementarrow_forwardTrue or False: By default, a JTextArea component does not perform line wrapping.arrow_forward
- describe the code in detail add comment lines package com.templatepattern; public class TemplatePatternTest1 { public static void main(String[] args) {String connectionString = "server=192.168.0.7";String username = "learner";String password = "designPatterns";StudentRegistration sr = new DatabaseBasedStudentRegistration(connectionString, username, password);System.out.println();Person p1 = new Person("patrick", "nick");System.out.println("Registering " + p1);sr.register(p1);System.out.println(); Person p2 = new Person("zayn", "nick");System.out.println("Registering " + p2);sr.register(p2);System.out.println();} } abstract class StudentRegistration {// template methodfinal Student register(Person person) {if (checkPerson(person)) {startOperation();try {int studentId = getNewIdentity(person);Student student = new Student(person, studentId);completeOperation();return student;}catch (Exception e) {cancelOperation();promptError(e.getMessage());}}else {promptError(person + " is not a valid…arrow_forwardJava programming This class is going to be used to represent an individual node in our graph1. Create a new class in your project, called Vertex2. This class must have the following attributes:• vertexNumber, which is an integer• colour, which is an integer• adjacencies, which is a LinkedList containing Vertex objects. These are the Vertex objects that are connected to the current Vertex by an edge.3. It must also have a constructor that takes in an integer in order to set the vertexNumber property.4. Note that the edge here is unweighted and undirected. This means that an edge between vertex 2 and vertex 5 is equally an edge between vertex 5 and vertex 2.5. In addition to the constructor, the Vertex class must have the following methods:• addAdjacency - takes in a Vertex object and adds it to the adjacencies LinkedList• isAdjacent - takes in a Vertex object and returns true if the given Vertex is adjacent to thecurrent Vertex object, and false otherwise• getDegree - returns the degree…arrow_forwardJava ProgramEdit this program that when you press the clear button, it actually clears the textfield and data of the previous numbers pressed.import java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import javax.swing.*;public class Pincode extends JPanel implements ActionListener {JLabel display, displayExtra;JButton numButton;JButton clr;JButton etr;String displayContent = "";String[] numPadContent = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "CLEAR", "0", "ENTER"};ArrayList<JButton> buttonList;String PASSWORD = "061904";JFrame f;Pincode(Container pane) {pane.setPreferredSize(new Dimension(320, 335));display = new JLabel(displayContent);displayExtra = new JLabel(displayContent);display.setPreferredSize(new Dimension(320, 25));display.setBorder(BorderFactory.createLoweredBevelBorder());pane.add(display,…arrow_forward
- Write a full program to create this following linkedlist and display it, then display only the EVEN numbers. You need to write the classes and only 3 method to insert,display and display the even numbers. (in java)arrow_forwardYou will implement some methods in the UndirectedGraph class. The UndirectedGraph class contains two nested classes, Vertex and Node, you should NOT change these classes. The graph will store a list of all the vertices in the graph. Each vertex has a pointer to its adjacent vertices. To get started, import the starter file, Undirected.java into the graphs package you create in a new Java Project. Please do not change any of the method signatures in the class, but you can add any helper methods you deem necessary. Implement the methods described below. You are free to test your code however you prefer. Vertex Class (DO NOT EDIT)The vertex class holds information about the vertices in the graph. It has an int val, a Vertex next that refers to the next vertex in the list of vertices (not necessarily an adjacent vertex), and a Node edge that starts the list of adjacent vertices. Node Class (DO NOT EDIT)This is a simple class to represent an adjacency list of a vertex in the graph.…arrow_forwardYou will implement some methods in the UndirectedGraph class. The UndirectedGraph class contains two nested classes, Vertex and Node, you should NOT change these classes. The graph will store a list of all the vertices in the graph. Each vertex has a pointer to its adjacent vertices. To get started, import the starter file, Undirected.java into the graphs package you create in a new Java Project. Please do not change any of the method signatures in the class, but you can add any helper methods you deem necessary. Implement the methods described below. You are free to test your code however you prefer. Vertex Class (DO NOT EDIT)The vertex class holds information about the vertices in the graph. It has an int val, a Vertex next that refers to the next vertex in the list of vertices (not necessarily an adjacent vertex), and a Node edge that starts the list of adjacent vertices. Node Class (DO NOT EDIT)This is a simple class to represent an adjacency list of a vertex in the graph.…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you