public Stack() { stackElements = new LinkedList(); }
private static void linkedlistTest() { LinkedList ll = new LinkedList(); Console.Out.WriteLine("======>LinkedList Test 1<======"); Console.Out.WriteLine(">>Tests whether or not nodes can be added to a linked list and that the getSize method works"); ll.insertAtFront("node 4"); ll.insertAtFront("node 3"); ll.insertAtFront("node 2"); ll.insertAtFront("node 1"); Console.Out.WriteLine("getSize() returned: " + ll.getSize()); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(ll.getSize() == 4); Console.Out.WriteLine(""); Console.Out.WriteLine("======>LinkedList Test 2<======"); Console.Out.WriteLine(">>Tests whether or not the linkedlist's toString method works"); Console.Out.WriteLine("toString() returned: " + ll.toString()); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(String.Equals(ll.toString(), "( node 1 , node 2 , node 3 , node 4 )")); Console.Out.WriteLine(""); Console.Out.WriteLine("======>LinkedList Test 3<======"); Console.Out.WriteLine(">>Tests whether or not the linkedlist's contains method works"); Console.Out.Write("contains(\"node 1\") returned: "); Console.Out.WriteLine(ll.contains("node 1")); Console.Out.Write("contains(\"node 5\") returned: "); Console.Out.WriteLine(ll.contains("node 5")); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(ll.contains("node 1") == true && ll.contains("node 5") == false); Console.Out.WriteLine(""); Console.Out.WriteLine("======>LinkedList Test 4<======"); Console.Out.WriteLine(">>Tests whether or not the linkedlist's deleteFromfront and delete methods work"); ll.deleteFromFront(); ll.delete("node 4"); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(ll.contains("node 1") == false && ll.contains("node 2") == true && ll.contains("node 3") == true && ll.contains("node 4") == false && ll.getSize() == 2 && String.Equals(ll.toString(), "( node 2 , node 3 )")); Console.Out.WriteLine(""); Console.Out.WriteLine("======>LinkedList Test 5<======"); Console.Out.WriteLine(">>Tests whether or not the linkedlist's getDataAtFront method works"); Console.Out.WriteLine("getDataAtFront() returned: " + ll.getDataAtFront()); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(String.Equals(ll.getDataAtFront(), "node 2")); Console.Out.WriteLine(""); }