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...
-
Determine the sample size needed to construct a 95% confidence interval to estimate the population proportion for the following sample proportions when the margin of error equals 4%: a. p = 0.30 b. p...
-
Keep a learning diary over the next few weeks logging anything that is relevant to your development area. Use the framework which Gwen used in a previous example (see Window on Practice box at the...
-
Hines stored her furniture, including a grand piano, in Arnetts warehouse. Needing more space, Arnett stored Hiness piano in Butlers warehouse next door. As a result of a fire, which occurred without...
-
Which of the following best clescribes an accrued expense? Question 31 Not yet answered Paints out of 125 Question Select one. a. An expense that has been paid in advance but hasn't been used yel lo...
-
4. The demand for ice cream during the three summer months (June, July, and August) at All-Flavors Parlor is estimated at 500, 600, and 400 20-gallon cartons, respectively. Two wholesalers, 1 and 2,...
-
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)...
-
How is the auditor's required confidence level influenced by control risk?
-
2. Ten bars of a certain quality are tested for their diameters. The results are given below. Test the hypothesis at a 95% level of confidence that the mean diameter of the bars produced by the...
-
Write out the state of the list while being sorted using the bubble sort algorithm. 5 8 3 6 9 5 Java code is required.
-
f(x) = 2 X x + 25 X local maximum value local minimum value Need Help? Read It
-
Airbed and Breakfast (428 words): The Startup Story of AirbnbBrian and Joe were flat mates in downtown San Francisco. In mid-2007, IDSA conference crowded downtown, filled all hotel rooms, and drove...
-
# We are testing Null: = 100 against Alternative: 100 using a sample size of 15. The critical values for t for a = .10 are
-
When a fair coin is flipped, we all know that the probability the coin lands on heads is 0.50. However, what if a coin is spun? According to the article Euro Coin Accused of Unfair Flipping in the...
-
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,...
-
(Present value)Sarah Wiggum would like to make a single investment and have $2.2 million at the time of her retirement in 35 years. She has found a mutual fund that will earn 7 percent annually. How...
-
Fraudulent financial reporting is an intentional misstatement or omission of amounts or disclosures with the intent to deceive users. Select one: True False
-
I am having trouble solving this problem on question #27. Can you please show me how to solve it step by step? Cost Mastery Problemi cost-Volume-Profit Analysis Cost Behavior Cover-to-Cover Company...
Study smarter with the SolutionInn App