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.10, Problem 28.10.3CP
Program Plan Intro
NineTailModel:
A “NineTailModel” is a java class, contains methods to find the shortest path from the source node to any other node. It contains following methods:
- NineTailModel()
- GetShortestPath(int)
- getEdges()
- getNode(int)
- getIndex(node:char[])
- flipCell(node:char[], int,int)
- printNode(node:char[])
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Fill in the missing code for the following "intercept" method, located within an "InterceptTokenService” class.
This method must add an “Authorization” header to the request with the value: "JWT token”, where token is the current, saved token.
NOTE: You may assume that an AuthService (injected into the class as "auth") provides a means of fetching the correct token using a "getToken()" method.
intercept(request: HttpRequest , next: HttpHandler): Observable {
// … your code here
}
Part 2: Sorting the WorkOrders via dates
Another error that will still be showing is that there is not Comparable/compareTo() method setup on the WorkOrder class file. That is something you need to fix and code. Implement the use of the Comparable interface and add the compareTo() method to the WorkOrder class.
The compareTo() method will take a little work here. We are going to compare via the date of the work order. The dates of the WorkOrder are saved in a MM-DD-YYYY format. There is a dash '-' in between each part of the date. You will need to split both the current object's date and the date sent through the compareTo() parameters.
You will have three things to compare against. You first need to check the year. If the years are the same value then you need to go another step to check the months, otherwise you compare them with less than or greater than and return the corresponding value. If you have to check the months it would be the same for years. If the months are the same you…
Goal 1: Update the Fractions Class
Here we will overload two functions that will used by the Recipe class later:
multipliedBy, dividedBy
Previously, these functions took a Fraction object as a parameter. Now ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer (affecting numerator/denominator of the returned object). For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6.
Goal 2: Update the Recipe Class
The Recipe constructors so far did not specify how many servings the recipe is for. We will now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (see sample output below for an…
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
- Goal 1: Update the Fractions Class Here we will overload two functions that will used by the Recipe class later: multipliedBy, dividedBy Previously, these functions took a Fraction object as a parameter. Now ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer (affecting numerator/denominator of the returned object). For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class Now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (sample output below for an example of formatting) . New Member functions to the Recipe Class: 1. Add four member functions…arrow_forwardPlease help me with this assignment below. I already have the code, you just need to fix something or add something in the code as what the assignment below requests. The assignment: Continue Exercise •• P13.1, checking the words against the /usr/share/dict/words on your computer, or the words.txt file in the companion code for this book. For a given number, only return actual words. The code of the resource class: import java.util.Scanner; public class U10P01R{ // This method to returns a character array containing all possible keypad // encodings for a digit in a standard phone char[] keysForButton(int n) { switch (n) { case 0: return new char[] { ' ' }; case 1: return new char[] { '.' }; case 2: return new char[] { 'A', 'B', 'C' }; case 3: return new char[] { 'D', 'E', 'F' }; case 4: return new char[] { 'G', 'H', 'I' }; case 5: return new char[] {…arrow_forwardI already have the code for the assignment below, but the code has an error in the driver class. Please help me fix it. The assignment: Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class. The resource class and the driver class need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code The code of the resource class: import java.util.ArrayList;import java.util.List; public class U10E03R{ // Recursive function to // print factors of a number public static void factors(int n, int i) { // Checking if the number is less than N if (i <= n) { if (n % i == 0) { System.out.print(i + " "); } // Calling the function recursively // for the next number factors(n, i +…arrow_forward
- Java Foundations : Please provide code and explain. Thank you. Write the code segments in main( ) and in methodA( ) for the following scenario: main( ) passes methodA an int variable called a. methodA generates an exception, but does not deal with it, if a is not between 1 and 100.arrow_forwardjavaarrow_forward3.25 Fixed Sized Deque Your task is to create an implementation of the Java Deque interface that can only hold N items where N is a number passed into the constructor. Note that most (if not all) of the unit tests rely on the method object[] toArray() inherited from Collection. Therefore, you must make sure you implement that method correctly in order to get most of the points. 301664.1524810.gpazay7 LAB АCTIVITY 3.25.1: Fixed Sized Deque 0/ 70 Submission Instructions Compile command javac FixedsizedDeque.java -xlint:all -encoding utf-8 We will use this command to compile your code Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. FixedSizedDeque.java Drag file here or Choose on hard drive.arrow_forward
- Read through the code and answer the following. List all the statements where the datatype of a reference might not be an exact match with the datatype of the object that it refers to. This is a kind of polymorphism. In the containsPoint method of Circle, why are x and y in scope, even though they are not defined as instance variables in Circle.java? Notice that x and y are declared as ‘protected’ in GridItem. Change this to ‘private’ and recompile. How does the compiler respond? How could Abstract Methods have been used to make the code cleaner? How might an Interface have been used to structure the classes? - Modify GridItem class below to make GridItem an abstract class. Make its getArea and containsPoint methods abstract. public class GridItem { protected int x; protected int y; public int getX() {return x;} public void setX(int value) {x = value;} public int getY() {return y;} public void setY(int value) {y = value;} public double getArea() { return 0; } public boolean…arrow_forwardIn GO language. Create a struct that has student name, id, and GPA. Write functions to create a student, modify the student’s id, and modify the student's GPA, and print the student’s information. (This is like creating a class and methods). Now create an array of three students and test your functions. You may hardcode your values if using a web conpiler. (Please hardcode the values!)arrow_forwardJava Programming: Add the components needed for lexer.java according to the rubric attached.The goal is to make sure to read the shank.txt file as a series of tokens & show the shank.txt printed in console of eclipse and the image of the output is attached. Make sure the lexer has all the state machines. Make sure to have main.java. There must be no error in the lexer at all. Below is the lexer.java and token.java. Lexer.java package mypack; import java.util.ArrayList;import java.util.List; public class Lexer { private static final int INTEGER_STATE = 1; private static final int DECIMAL_STATE = 2; private static final int IDENTIFIER_STATE = 3; private static final int ERROR_STATE = 4; private static final char EOF = (char) -1; private static String input; private static int index; private static char currentChar; public List<Token> lex(String inputString) throws Exception { input = inputString; index = 0; currentChar =…arrow_forward
- 11.8 At what point does the Java environment complain about your passinga non-Comparable value to an OrderedVector?11.9 Write the compareTo method for the String class.11.10 Write the compareTo method for a class that is to be ordered by a field,key, which is a double. Be careful: The result of compareTo must be an int.arrow_forwardDefine buildListBackward function.arrow_forwardWrite the definitions of the member functions of the classes arrayListType and unorderedArrayListType that are not given in this chapter. The specific methods that need to be implemented are listed below. Implement the following methods in arrayListType.h: isEmpty isFull listSize maxListSize clearList Copy constructor Implement the following method in unorderedArrayListType.h insertAt Also, write a program (in main.cpp) to test your function.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning