/* TestLL.java CIS 260 2016-03-28 David Klick Program used to test LinkedList class. */ public class TestLL { public static void main(String[] args) { LinkedList lst = new LinkedList<>(); System.out.println("Length of new list: " + lst.length()); System.out.println("Adding 1, 2, 3"); lst.add(1).add(2).add(3); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("Add front 42, add back 19"); lst.addFront(42).addBack(19); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("Adding 20...25 to front"); for (int i=20; i<=25; i++) lst.addFront(i); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("The first item in the list is: " + lst.front()); System.out.println("The last item in the list is: " + lst.back()); System.out.println("Removing two items from front"); int item1 = lst.removeFront(); int item2 = lst.removeFront(); System.out.println("Removed: " + item1 + ", " + item2); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("Removing two items from back"); item1 = lst.removeBack(); item2 = lst.removeBack(); System.out.println("Removed: " + item1 + ", " + item2); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("Removing item '20'"); if (!lst.remove(20)) System.out.println("Failed!"); System.out.println("Removing item '31'"); if (!lst.remove(31)) System.out.println("Failed!"); System.out.println("Length of new list: " + lst.length()); System.out.println("List: " + lst); System.out.println("Clearing list"); while (!lst.isEmpty()) { lst.removeFront(); System.out.println("List: " + lst); } System.out.println("Length of new list: " + lst.length()); } }