Question: do required steps in java public class A3LinkedList implements A3List { private A3Node head; private A3Node tail; private int length; public A3LinkedList() { head =








public class A3LinkedList implements A3List { private A3Node head; private A3Node tail; private int length; public A3LinkedList() { head = null; tail = null; length = 0; } public void addFront(String s) { } public void addBack(Strings) { public int size() { return length; public boolean isEmpty() { return lengthuse; } public void removeFront() { } public void removeBack() { 3 public void rotate(int n) { } public void interleave(ASLinkedList other) { } /Purpose: return a string representation of the list when traversed from front to back * Parameters: none Returns: nothing public String frontToBack() { String result = "C": A3Node cur = heads while (cur != null) { stat 1Purpose: return a string representation of the list when traversed from front to back * Parameters: none Returns: nothing */ public String frontToBack() { String result = "{"; A3Node cur = head; while (cur != null) { result += cur.getData(); cur = cur.next; result + "}": return result; . 1 Purpose: return a string representation of the list when traversed from back to front - Parameters: none Returns: nothing * public String backToFront() { String result - "": A3Node cur = tail; while (cur le null) { result - cur.getData(); cur - cur.prev: result ): return result: Type here to search public class A3Node { private String data; protected A3Node prev; protected A3Node next; public A3Node(String data) { this.data = data; prev = null; next = null; public String getData() { return data; } public A3Node getPrev() { return prev; 3 public A3Node getNext() { return next; public void setNext (A3Node next) {. this.next - next; 3 public void setPrev(A3Node prev) { this.prev - prev; public String toString() { return data; public interface A3List / Purpose: adds to the front of the list Parameters: Strings - the string to add Returns: nothing Precondition: s is not null / public void addFront(String s); 1 Purpose: adds to the back of the list * Parameters: Strings - the string to add Returns: nothing * Precondition: s is not null */ public void addBack (String s); /* Purpose: get the current size of the list Parameters: none Returns: int number of elements in list */ public int size(); /* Purpose: determines if the list is empty Parameters: none Returns: boolean - true if empty, false otherwise public boolean isEmpty(); /* Purpose: removes the element from the front of the list Parameters: none * Returns: nothing */ public void removeFront(): /* Purpose: removes the element from the back of the list * Parameters: none Returns: nothing * public void removeBack(); /* Purpose: rotates the elements in the list right by n spots Parameters: int n - number of positions to rotate Returns: nothing Precondition: ne * Example: Given a list (a, b, c, d, e, f) and n=2, each item would be rotated right two positions. Elements that 'rotate' off the back appear at the front, resulting in fe, f, a, b, c, d} public void rotate(int n): / Purpose: interleaves this list with another list Parameters: A3Linkedlist other - the list to interleave with Returns: nothing - Precondition: Both lists are the same size, with size > 1 Example: If lista: (al, a2, a3, 24, 25) at the front, resulting in {e, f, a, b, c, d) public void rotate(int n); Purpose: interleaves this list with another list Parameters: A3Linkedlist other - the list to interleave with Returns: nothing Precondition: Both lists are the same size, with size > 1 Example: If lista: (al, a2, a3, a4, a5) and listB: {61, 62, 63, 64, 65) and the two lists were interleaved, the result would be lista: (al, b2, a3, 64, a5) and listB: {bi, a2, b3, a4, b5). NOTE: The video link in the pdf provides a visual example */ public void interleave(A3Linkedlist other); Type here to search public class A3Tester { private static int testPassCount = 0; private static int testCount = 0; public static void main(String[] args) { // Uncomment each method one at a tine, 1/ and implement the method in A3Linkedlist.java // until all tests pass. It is strongly // recommended that you add additional tests // to ensure the correctness of your implementation. testAddFront(); testAddBack(); testSizeAndIsEmpty(); testRemoveFront; testRemoveBackO; testRotate(); test Interleave(); System.out.println("Passed " + testPassCount + "/" + testCount + tests"); public static void testAddFront() { String result = ""; A3Linkedlist listi - new A3Linkedlist(); result listi. frontToBack(); displayResults (result.equals("(", "testAddFront"); list1.addFront("A"); result listi. frontToBack(); displayResults (result.equals("(A)", "testAddFront"); listi.addFront(""); list1.addFront("A"); listi.addFront(""); result listi. frontToBack(): displayResults(result.equals("JAVA)"), "testAddFront"): result = listi.back ToFront(; displayResults(result.equals("CAVA))"). "testAddFront"); ) public static void testAddBack() { // String result // A3Linkedlist listi - new A3Linkedlist(); // result - listi.frontToBack(); W displayResults(result.equals(""), "testAddBack"): 1/ listi.addback(""); 17 result = listi.frontToBlack(); V/ displayResults (result.equals("(F)"). "test AddBack"); 1+1 // listi.addBack("U"); // list1.addBack("N"); // result = listi.frontToBack(); // displayResults(result.equals("{FUN}"), "testAddBack"); 11 result = list1.backToFront(); // displayResults(result.equals("{NUF}"), "testAddBack"); public static void testSizeAndIsEmpty() { // int result - @; // A3Linkedlist listi = new A3LinkedList(); // result = list1.size(): // displayResults(results=0, "testSizeAndIsEmpty"); // displayResults(listi.isEmpty()==true, "testSizeAndIsEmpty"); // list1.addFront("C"); // listi.addFront("S"); W/ listi.addFront("C"); // result = listi.size(): J/ displayResults (resulta=3, "testSizeAndIsEmpty"); // displayResults(listi.isEmptyO==false, "testSizeAndIsEmpty"); // listi.addBack("115"); // result = listi.size(); // displayResults (result 4, "testSizeAndIsEmpty"); } public static void testRemoveFront() { // String result = "; // A3Linkedlist listi - new A3LinkedList(); // listi. addBack("P"); // listi.addBack("I"); // listi.addBack("N"); // listi.addBack("K"); // result = listi.frontToBack(); // displayResults(result.equals("(PINK}"), "test RemoveFront"); 1/ listi.removeFront(); // result = listi. frontToBack(); // displayResults(result.equals("{INK"), "testRemoveFront) /* Write additional tests here to ensure all of your pointers have been updated correctly. You should also ensure that your size and IsEmpty methods work with removal as well as addition public static void testRemoveBack() { Write all of your own tests here 3 . public static void testRotate() { // String result = // A3LinkedList list1 = new A3Linkedlist(); // listi.addBack("A"); 1/ listi.addBack("B"); 1/ list1.addBack("C"); // listi. addBack("D"); 11 listi.addBack("E"); 1/ listi.addBack("F"); 1/ listi.addBack("G"); // result = listi.frontToBack(); Il displayResults(result.equals("{ABCDEFG}"), "testRotate"); // listi.rotate(1); Il result = listi.frontToBack(); 1/ displayResults(result.equals("{GABCDEF)"), "testRotate"); V/ list1.rotate(3); 11 result = listi. frontToBack(); 1/ displayResults(result.equals("{DEFGABC)"), "testRotate"); 1 Write additional tests here to ensure all of your pointers have been updated correctly. */ public static void testInterleave() { // ALinkedList listi = new A3Linkedlist(); // ALinkedlist list2 = new A3Linkedlist(); 1/ String resulti = ""; 1/ String result2 1 listi. addback("A"); // listi.addBack("B"); 1/ list1.addBack("C"); // listi.addback("0"); // listi.addback(""); Il listi.addback("F"); 1/ listi.addBack(""); 17 resulti-listi. frontToBack: 1/ displayResults(resulti.equals("CABCDEFG)"), "test Interleave"); 11 list2.addback("L"); 1 list2.addback(""); 11 list2.addback(""); 1 list2.addback(0); Il list 2. addback(""); V list2.addback(""); 1 list2.addliack(R) 1 result2 - list 2. frontToBack(); // displayResultsfresult2.equals("PROPON)"), "testinterleave"); 1 listi.interleave(list); 1 results - listi. frontToBack(): W result - list frontToBlack PUOLIC SLOLIL VOU LESLLerreavet 1/ A3Linkedlist listi = new A3LinkedList(); // A3LinkedList list2 = new A3Linkedlist(); I String resulti = ""; // String result2 = ""; // list1.addBack("A"); W listi.addBack("B"); // listi, addBack("C"); // list1.addBack(""); // listi.addBack("E"); // listi.addBack(""); // listi.addBack("G"); 17 resulti listi. frontToBack(); // display Results(resulti.equals("(ABCDEFG)"), "test Interleave"); // list2.addBack("L"); 7/ list2.addBack ("M"); // list 2. addBack ("N"); // list2.addBack("0"); // list2.addBack ("P"); // list2.addBack("Q"); 11 list2.addBack("R"); // result2 - list2. frontToBack(): // displayResults(result2.equals("(LMNOPOR)"), "test Interleave"); // listi interleave(list2) W/ resulti listi. frontToBack(); // result2 = list 2. frontToBack(; // displayResults(resulti.equals("CAMCOEQG)"), "test Interleave"); W/ displayResults(result2.equals("{LONDPFR)"), "test Interleave"); /* Write additional tests here to ensure all of your pointers have been updated correctly. / 1 public static void displayResults (boolean passed, String testName) There is some magic going on here getting the line number Borrowed from http://10.taracana.com/index.php/archive/core-Java-how-to-get-java-source-code-line number-file-name-in-code/ */ testCount 11 passed) System.out.printin ("Passed test testne): testPassCount++; ) System.out.printin (Falled test testnane." at line Thread.current Thread().setStackTrace().getLineNumber() public class A3LinkedList implements A3List { private A3Node head; private A3Node tail; private int length; public A3LinkedList() { head = null; tail = null; length = 0; } public void addFront(String s) { } public void addBack(Strings) { public int size() { return length; public boolean isEmpty() { return lengthuse; } public void removeFront() { } public void removeBack() { 3 public void rotate(int n) { } public void interleave(ASLinkedList other) { } /Purpose: return a string representation of the list when traversed from front to back * Parameters: none Returns: nothing public String frontToBack() { String result = "C": A3Node cur = heads while (cur != null) { stat 1Purpose: return a string representation of the list when traversed from front to back * Parameters: none Returns: nothing */ public String frontToBack() { String result = "{"; A3Node cur = head; while (cur != null) { result += cur.getData(); cur = cur.next; result + "}": return result; . 1 Purpose: return a string representation of the list when traversed from back to front - Parameters: none Returns: nothing * public String backToFront() { String result - "": A3Node cur = tail; while (cur le null) { result - cur.getData(); cur - cur.prev: result ): return result: Type here to search public class A3Node { private String data; protected A3Node prev; protected A3Node next; public A3Node(String data) { this.data = data; prev = null; next = null; public String getData() { return data; } public A3Node getPrev() { return prev; 3 public A3Node getNext() { return next; public void setNext (A3Node next) {. this.next - next; 3 public void setPrev(A3Node prev) { this.prev - prev; public String toString() { return data; public interface A3List / Purpose: adds to the front of the list Parameters: Strings - the string to add Returns: nothing Precondition: s is not null / public void addFront(String s); 1 Purpose: adds to the back of the list * Parameters: Strings - the string to add Returns: nothing * Precondition: s is not null */ public void addBack (String s); /* Purpose: get the current size of the list Parameters: none Returns: int number of elements in list */ public int size(); /* Purpose: determines if the list is empty Parameters: none Returns: boolean - true if empty, false otherwise public boolean isEmpty(); /* Purpose: removes the element from the front of the list Parameters: none * Returns: nothing */ public void removeFront(): /* Purpose: removes the element from the back of the list * Parameters: none Returns: nothing * public void removeBack(); /* Purpose: rotates the elements in the list right by n spots Parameters: int n - number of positions to rotate Returns: nothing Precondition: ne * Example: Given a list (a, b, c, d, e, f) and n=2, each item would be rotated right two positions. Elements that 'rotate' off the back appear at the front, resulting in fe, f, a, b, c, d} public void rotate(int n): / Purpose: interleaves this list with another list Parameters: A3Linkedlist other - the list to interleave with Returns: nothing - Precondition: Both lists are the same size, with size > 1 Example: If lista: (al, a2, a3, 24, 25) at the front, resulting in {e, f, a, b, c, d) public void rotate(int n); Purpose: interleaves this list with another list Parameters: A3Linkedlist other - the list to interleave with Returns: nothing Precondition: Both lists are the same size, with size > 1 Example: If lista: (al, a2, a3, a4, a5) and listB: {61, 62, 63, 64, 65) and the two lists were interleaved, the result would be lista: (al, b2, a3, 64, a5) and listB: {bi, a2, b3, a4, b5). NOTE: The video link in the pdf provides a visual example */ public void interleave(A3Linkedlist other); Type here to search public class A3Tester { private static int testPassCount = 0; private static int testCount = 0; public static void main(String[] args) { // Uncomment each method one at a tine, 1/ and implement the method in A3Linkedlist.java // until all tests pass. It is strongly // recommended that you add additional tests // to ensure the correctness of your implementation. testAddFront(); testAddBack(); testSizeAndIsEmpty(); testRemoveFront; testRemoveBackO; testRotate(); test Interleave(); System.out.println("Passed " + testPassCount + "/" + testCount + tests"); public static void testAddFront() { String result = ""; A3Linkedlist listi - new A3Linkedlist(); result listi. frontToBack(); displayResults (result.equals("(", "testAddFront"); list1.addFront("A"); result listi. frontToBack(); displayResults (result.equals("(A)", "testAddFront"); listi.addFront(""); list1.addFront("A"); listi.addFront(""); result listi. frontToBack(): displayResults(result.equals("JAVA)"), "testAddFront"): result = listi.back ToFront(; displayResults(result.equals("CAVA))"). "testAddFront"); ) public static void testAddBack() { // String result // A3Linkedlist listi - new A3Linkedlist(); // result - listi.frontToBack(); W displayResults(result.equals(""), "testAddBack"): 1/ listi.addback(""); 17 result = listi.frontToBlack(); V/ displayResults (result.equals("(F)"). "test AddBack"); 1+1 // listi.addBack("U"); // list1.addBack("N"); // result = listi.frontToBack(); // displayResults(result.equals("{FUN}"), "testAddBack"); 11 result = list1.backToFront(); // displayResults(result.equals("{NUF}"), "testAddBack"); public static void testSizeAndIsEmpty() { // int result - @; // A3Linkedlist listi = new A3LinkedList(); // result = list1.size(): // displayResults(results=0, "testSizeAndIsEmpty"); // displayResults(listi.isEmpty()==true, "testSizeAndIsEmpty"); // list1.addFront("C"); // listi.addFront("S"); W/ listi.addFront("C"); // result = listi.size(): J/ displayResults (resulta=3, "testSizeAndIsEmpty"); // displayResults(listi.isEmptyO==false, "testSizeAndIsEmpty"); // listi.addBack("115"); // result = listi.size(); // displayResults (result 4, "testSizeAndIsEmpty"); } public static void testRemoveFront() { // String result = "; // A3Linkedlist listi - new A3LinkedList(); // listi. addBack("P"); // listi.addBack("I"); // listi.addBack("N"); // listi.addBack("K"); // result = listi.frontToBack(); // displayResults(result.equals("(PINK}"), "test RemoveFront"); 1/ listi.removeFront(); // result = listi. frontToBack(); // displayResults(result.equals("{INK"), "testRemoveFront) /* Write additional tests here to ensure all of your pointers have been updated correctly. You should also ensure that your size and IsEmpty methods work with removal as well as addition public static void testRemoveBack() { Write all of your own tests here 3 . public static void testRotate() { // String result = // A3LinkedList list1 = new A3Linkedlist(); // listi.addBack("A"); 1/ listi.addBack("B"); 1/ list1.addBack("C"); // listi. addBack("D"); 11 listi.addBack("E"); 1/ listi.addBack("F"); 1/ listi.addBack("G"); // result = listi.frontToBack(); Il displayResults(result.equals("{ABCDEFG}"), "testRotate"); // listi.rotate(1); Il result = listi.frontToBack(); 1/ displayResults(result.equals("{GABCDEF)"), "testRotate"); V/ list1.rotate(3); 11 result = listi. frontToBack(); 1/ displayResults(result.equals("{DEFGABC)"), "testRotate"); 1 Write additional tests here to ensure all of your pointers have been updated correctly. */ public static void testInterleave() { // ALinkedList listi = new A3Linkedlist(); // ALinkedlist list2 = new A3Linkedlist(); 1/ String resulti = ""; 1/ String result2 1 listi. addback("A"); // listi.addBack("B"); 1/ list1.addBack("C"); // listi.addback("0"); // listi.addback(""); Il listi.addback("F"); 1/ listi.addBack(""); 17 resulti-listi. frontToBack: 1/ displayResults(resulti.equals("CABCDEFG)"), "test Interleave"); 11 list2.addback("L"); 1 list2.addback(""); 11 list2.addback(""); 1 list2.addback(0); Il list 2. addback(""); V list2.addback(""); 1 list2.addliack(R) 1 result2 - list 2. frontToBack(); // displayResultsfresult2.equals("PROPON)"), "testinterleave"); 1 listi.interleave(list); 1 results - listi. frontToBack(): W result - list frontToBlack PUOLIC SLOLIL VOU LESLLerreavet 1/ A3Linkedlist listi = new A3LinkedList(); // A3LinkedList list2 = new A3Linkedlist(); I String resulti = ""; // String result2 = ""; // list1.addBack("A"); W listi.addBack("B"); // listi, addBack("C"); // list1.addBack(""); // listi.addBack("E"); // listi.addBack(""); // listi.addBack("G"); 17 resulti listi. frontToBack(); // display Results(resulti.equals("(ABCDEFG)"), "test Interleave"); // list2.addBack("L"); 7/ list2.addBack ("M"); // list 2. addBack ("N"); // list2.addBack("0"); // list2.addBack ("P"); // list2.addBack("Q"); 11 list2.addBack("R"); // result2 - list2. frontToBack(): // displayResults(result2.equals("(LMNOPOR)"), "test Interleave"); // listi interleave(list2) W/ resulti listi. frontToBack(); // result2 = list 2. frontToBack(; // displayResults(resulti.equals("CAMCOEQG)"), "test Interleave"); W/ displayResults(result2.equals("{LONDPFR)"), "test Interleave"); /* Write additional tests here to ensure all of your pointers have been updated correctly. / 1 public static void displayResults (boolean passed, String testName) There is some magic going on here getting the line number Borrowed from http://10.taracana.com/index.php/archive/core-Java-how-to-get-java-source-code-line number-file-name-in-code/ */ testCount 11 passed) System.out.printin ("Passed test testne): testPassCount++; ) System.out.printin (Falled test testnane." at line Thread.current Thread().setStackTrace().getLineNumber()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
