public class AutoTest { /// This class tests your LinkedList code public static void main(String[] args) { LinkedList ls = new LinkedList(); System.out.println("LinkedList is empty: " + ls.isEmpty()); System.out.println("The size is: " + ls.size()); System.out.println(ls); String s1 = "I"; String s2 = "Love"; String s3 = "CS 1316"; System.out.println( "About to add the first three node using addFirst(data)"); ls.addFirst(s3); ls.addFirst(s2); ls.addFirst(s1); System.out.println( "... Done. As of now... "); System.out.println("LinkedList is empty: " + ls.isEmpty()); System.out.println("The size is: " + ls.size()); System.out.println(ls); System.out.println("\nAbout to test getFirst().. " ); System.out.println("The data in the first node is: " + ls.getFirst().toString()); System.out.println("\nAbout to test contains(item).."); System.out.println("Contains \"Hello\": " + ls.contains("Hello"));// Should be FALSE System.out.println("Contains the data in the first node: " + ls.contains(ls.getFirst())); // Should be TRUE; System.out.println( "\nAbout to test set(index, data), using good AND bad inputs "); ls.set(2, "Weekends"); ls.set(0, "We"); ls.set(-1, "I'm on a boat"); // bad input. no effect ls.set(ls.size(), "Flippie floppies"); // bad input. no effect System.out.println( "... Done. As of now... "); System.out.println("LinkedList is empty: " + ls.isEmpty()); System.out.println("The size is: " + ls.size()); System.out.println(ls); System.out.println("\nAbout to test addNode(index, data), using good AND bad inputs"); ls.addNode(1, "All"); ls.addNode(0, "Yes,");// adds a node in the first position (index of 0). ls.addNode(ls.size() + 1, "Tech"); // bad input; no effect ls.addNode(-1, "Geico");// bad input, no effect. System.out.println( " ... Done. As of now..."); System.out.println("LinkedList is empty: " + ls.isEmpty()); System.out.println("The size is: " + ls.size()); System.out.println(ls); System.out.println("\nAbout to test removeNthNode(index) using good AND bad inputs."); ls.removeNthNode(0); // removes the first node. ls.removeNthNode(ls.size()-1);// removes the last node ls.removeNthNode(-100000);// bad input; no effect. ls.removeNthNode(ls.size()); // bad input; no effect. System.out.println("...Done. As of now.."); System.out.println("LinkedList is empty: " + ls.isEmpty()); System.out.println("The size is: " + ls.size()); System.out.println(ls); } }