Design and write a complete test program to test if the MyLinkedList class in Listing 24.6 meets
Question:
Design and write a complete test program to test if the MyLinkedList class in Listing 24.6 meets all requirements.
Listing
Transcribed Image Text:
1 public class MyLinkedList
1 public class MyLinkedList extends MyAbstractlist { private Node head, tail; /** Create a default list */ public MyLinkedList() { /** Create a list from an array of objects */ public MyLinkedList(E[] objects) { super (objects); 10 11 { 12 13 /** Return the head element in the list */ public E getFirst() { if (size == 0) { return null; 14 15 16 17 18 else { return head.element; 19 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 /** Return the last element in the list */ public E getlast() { if (size == 0) { return null; else { return tail.element; /** Add an element to the beginning of the list */ public void addFirst(E e) { // Implemented in Section 24.4.3.1, so omitted here 36 37 38 /** Add an element to the end of the list */ public void addLast (E e) { // Implemented in Section 24.4.3.2, so omitted here 39 40 41 42 43 @0verride /** Add a new element at the specified index * in this list. The index of the head element is 0 */ public void add(int index, E e) { // Implemented in Section 24.4.3.3, so omitted here 44 45 46 47 { 48 49 /** Remove the head node and return the object that is contained in the removed node. */ public E removeFirst() { // Implemented in Section 24.4.3.4, so omitted here 50 51 52 53 54 55 /** Remove the last node and return the object that is contained in the removed node. */ public E removelast() { // Implemented in Section 24.4.3.5, so omitted here 56 57 58 59 60 61 @Override /** Remove the element at the specified position in this list. Return the element that was removed from the list. */ public E remove(int index) { // Implemented earlier in Section 24.4.3.6, so omitted here 62 63 64 65 66 67 @Override public String toString() { StringBuilder result = new StringBuilder("["); 68 69 70 71 Node current = head; for (int i = 0; i < size; i++) { result.append(current.element); current = current.next; if (current != null) { result.append(", "); // Separate two elements with a comma 72 73 74 75 76 77 else { result.append("]"); // Insert the closing ] in the string 78 79 80 81 82 83 return result.toString(); 84 85 86 87 @Override /** Clear the list */ public void clear() { size = 0; head = tail - null; 88 89 90 91 92 93 @Override /** Return true if this list contains the element e * / public boolean contains(E e) { System.out.print1n("Implementation left as an exercise"); 94 95 return true; 96 97 98 @Override /** Return the element at the specified index */ public E get(int index) { System.out.printIn("Implementation left as an exercise"); return null; 99 100 101 102 103 104 @Override /** Return the index of the head matching element * in this list. Return -1 if no match. */ public int index0f (E e) { System.out.printIn("Implementation left as an exercise"); return 0; 105 106 107 108 109 110 111 @Override /** Return the index of the last matching element in this list. Return -1 if no match. */ public int lastIndexOf(E e) { System.out.println("Implementation left as an exercise"); 112 113 114
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 64% (14 reviews)
Program Plan Create a MyLinkedListTestProgram class for the test of MyLinkedList class This MyLinkedList class extends MyAbstractList class which impl...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Design and write a complete test program to test if the BST class in Listing 25.5 meets all requirements. Listing 1 public class BST 2 extends AbstractTree { protected TreeNode root; protected int...
-
Design and write a complete test program to test if the MyArrayList class in Listing 24.3 meets all requirements. Listing 1 public class MyArrayList extends MyAbstractList { public static final int...
-
Design and write a complete test program to test if the AVLTree class in Listing 26.4 meets all requirements. Listing 1 public class TestAVLTree { public static void main(String[] args) { // Create...
-
Are the marks one receives in a course related to the amount of time spent studying the subject? To analyze this mysterious possibility, a student took a random sample of 10 students who had enrolled...
-
A set S is a convex cone if and only if 1. S S for every 0 2. S + S S Convex cones arise naturally in economics, where quantities are required to be nonnegative. The set of nonnegative prices...
-
The Haber Company purchased land in Arizona on which uranium had been discovered. The cost of the land was $1,000,000. Additional costs necessary to prepare the land for mining operations were...
-
In 1951, DuPont began using the chemical perfluorooctanoic acid to manufacture Teflon. Due to the dangerous nature of the chemical, DuPont was given special instructions by its supplier to dispose of...
-
At December 31, 2010, Fell Corporation had a deferred tax liability of $680,000, resulting from future taxable amounts of $2,000,000 and an enacted tax rate of 34%. In May 2011, a new income tax act...
-
Need help with this relational model, please. I am having trouble understanding how to create the relational model.
-
Allison is paid $1,520 per week. What is the amount of federal income tax withheld from Allisons paycheck under the following conditions? Use the percentage method table in the Appendix to this...
-
Add the following new methods in?BST. /** Displays the nodes in a breadth-first traversal */ public void breadthFirstTraversal() /** Returns the height of this binary tree */ public int height()
-
Define an iterator class named PrimeIterator for iterating prime numbers. The constructor takes an argument that specifies the limit of the maximum prime number. For example, new PrimeIterator(23302)...
-
We-Linc is a social media and networking platform designed and managed by We-Linc Ltd. The platform helps users to connect with people who have similar interests or backgrounds. It also enables users...
-
A commercial bank has reserves of $308, loans of $1,092 and checkable deposits of $1,400. At the current required reserve ratio, this bank claims to have exactly zero excess reserves. Then the...
-
A square rectangular pipe (sides of length a) runs parallel to the z-axis (from - to +o). V-V. (constant) on this surface y V-0 on this surface on this surface The 4 sides are maintained with...
-
Karen is upset with her supervisor because she was denied her requested vacation days. She is experiencing a very low level of job satisfaction but cannot afford to quit her job. Describe three...
-
You are considering a portfolio consisting of investments in the stocks Lozada Inc. and Soppie Inc. Returns on the 2 stocks under various conditions are shown below. Probability 0.05 0.25 0.40 0.25...
-
I am required to conduct a survey of my own and present the data to my principal property practitioner in the format of a report on the following scope: I have to Measure the response rate of the...
-
The March bank statement showed the following for Yap Co: Additional information: 1. The bank statement contained three debit memoranda: ¢ An NSF cheque of $595 that Yap had deposited was...
-
Vince, Inc. has developed and patented a new laser disc reading device that will be marketed internationally. Which of the following factors should Vince consider in pricing the device? I. Quality of...
-
Assume we have created a packet-switched internet. Using the TCP/IP protocol suite, we need to transfer a huge file. What are the advantage and disadvantage of sending large packets?
-
A host communicates with another host using the TCP/IP protocol suite. What is the unit of data sent or received at each of the following layers? a. Application layer b. Network layer c. Data-link...
-
Assume a system uses five protocol layers. If the application program creates a message of 100 bytes and each layer (including the fifth and the first) adds a header of 10 bytes to the data unit,...
-
1. A businessman travels between the cities of the following graph. The travel pattern is that he stays in one of the cities for the whole day, and on the next day, he travels to one of the...
-
How do historical legacies of colonialism, imperialism, and systemic injustice continue to shape contemporary power structures, and what steps can be taken to address and redress these historical...
-
Izabella is 20 years old. Eighteen months ago, she started selling some of her old clothing which no longer suited her on peer-to-peer social shopping apps such as Letgo and Depop. She was surprised...
Study smarter with the SolutionInn App