Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12.3, Problem 23STQ
Explanation of Solution
Reasons for not taking accessor and mutator methods for class definition of “ListNode”:
The given methods are not needed for the class definition “ListNode” of Listing 12.7 because the methods in the linked list class can directly access the instance variables “data” and “link” of the nodes.
- Consider the method “showList” of “StringLinkedListSelfContained...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design and implement a Java class named Book with two data members: title and price. The class should have suitable constructors, get/set methods, and the toString method. Design and implement another Java class named BookShelf which has an ArrayList data member named bookList to store books. The class should have suitable constructors, get/set methods, and the toString method, as well as methods for people to add a book (prototype: addBook(Book book)), remove a book (prototype: removeBook(Book book)), and search for a book (prototype: findBook(Book book)). Test the two classes by creating a Bookshelf object and five Book objects. Add the books to the bookshelf. Display the contents of the bookshelf. Test the removeBook and findBook methods as well. Take screenshots of your tests and submit them with your Java code (not the whole project)
Alert -Don't submit AI generated answer and i need unique response only if I see plagiarism then I'll reduce rating for sure.
Alert -Don't submit AI generated answer and i need unique response only if I see plagiarism then I'll reduce rating for sure.
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Similar questions
- JAVA CODE Learning Objectives: Detailed understanding of the linked list and its implementation. Practice with inorder sorting. Practice with use of Java exceptions. Practice use of generics. You have been provided with java code for SomeList<T> class. This code is for a general linked list implementation where the elements are not ordered. For this assignment you will modify the code provided to create a SortedList<T> class that will maintain elements in a linked list in ascending order and allow the removal of objects from both the front and back. You will be required to add methods for inserting an object in order (InsertInorder) and removing an object from the front or back. You will write a test program, ListTest, that inserts 25 random integers, between 0 and 100, into the linked list resulting in an in-order list. Your code to remove an object must include the exception NoSuchElementException. Demonstrate your code by displaying the ordered linked list and…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_forwardPart 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…arrow_forward
- Exercise 1• Create a class that sorts a list in ascending order. Make use of the Collections method sort• The list should be a list of Strings.• Test your code with {“Hearts”, “Diamonds”, “Clubs”, “Spades”}• Before and after the sort, use the implicit call to the list’s toString method to output the list contents. Exercise 2• Create a class with the same requirement as in Exercise 1, but the sort should be in descending order• Make use of the Comparator interface• Make use of the static collection method reverseOrder javaarrow_forwardIn Kotlin, use this Employee class Use this Employee class data class Employee(val name: String, val wage: Double, val hours: Double) and this list of Employees: val l: List = listOf(Employee("Bob", 34.33, 42.0), Employee ("Cathy", 27.33, 15.25), Employee("Carlos", 46.99, 38.75), Employee("Tomas", 49.66,28.45), Employee("Xavier", 34.56, 11.5)) Write a function called formatPaycheck that takes a Pair and returns a String. formatPaycheck should use the two parts of the Pair to put together and return a String like this, with the paycheck amount shown to two digits past the decimal point: Pay to the order of Cathy $359.47 Use raise() to raise all the Employees' pay by 15%. Then use map with the payroll and formatPaycheck functions to get a list of the paychecks in the format shown above. Print the result. The output should look like this: [Pay to the order of Bob $1077.79, Pay to the order of Cathy $359.47, Pay to the order of Carlos $1361.09, Pay to the order of Tomas $1056.09,…arrow_forwardHelp with c++... please paste indented code plzz and keep output same as givenarrow_forward
- Java Code: Create a Parser class. Much like the Lexer, it has a constructor that accepts a LinkedList of Token and creates a TokenManager that is a private member. The next thing that we will build is a helper method – boolean AcceptSeperators(). One thing that is always tricky in parsing languages is that people can put empty lines anywhere they want in their code. Since the parser expects specific tokens in specific places, it happens frequently that we want to say, “there HAS to be a “;” or a new line, but there can be more than one”. That’s what this function does – it accepts any number of separators (newline or semi-colon) and returns true if it finds at least one. Create a Parse method that returns a ProgramNode. While there are more tokens in the TokenManager, it should loop calling two other methods – ParseFunction() and ParseAction(). If neither one is true, it should throw an exception. bool ParseFunction(ProgramNode) bool ParseAction(ProgramNode) -Creates ProgramNode,…arrow_forwardIn C++, Write the implementation for the methods of the Node class including the constructor. The constructor should set value to the passed in parameter, and set the value of the next pointer to NULL. getNext() should return the value of the next pointer. setNext() should set the value of the next pointer to the parameter that is passed in. In the main() function below (where it says // Step 2 code here), write the code to make a list of 10 Node objects. To do this, make a root pointer which is a pointer to a Node object, and then use a loop to create new Nodes, hooking up the list using setNext() and getNext() for each node. Set the value of each new Node to be the even numbers 2 through 18 (in addition to the root node which has value 0). Make sure that your nodes are linked together! Write code to step through your linked list (where it says // Step 3 code here), printing the value of each node. Write code to clean up the list (where it says // Step 4 code here). Print a…arrow_forwardLab 10 Using an interface to share methods It is often the case that two or more classes share a common set of methods. For programming purposes we might wish to treat the objects of those classes in a similar way by invoking some of their common routines.For example, the Dog and Cat classes listed below agree on the void method speak. Because Dog and Cat objects have the ability to “speak,” it is natural to think of putting both types of objects in an ArrayList and invoking speak on every object in the list. Is this possible? Certainly we could create an ArrayList of Dog that would hold all the Dog objects, but can we then add a Cat object to an ArrayList of Dog?Try running the main program below as it is written. Run it a second time after uncommenting the line that instantiates a Cat object and tries to add it to the ArrayList. import java.util.*;public class AnimalRunner{ public static void main(String[] args) { ArrayList<Dog> dogcatList = new ArrayList<Dog>();…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