Ejemplo n.º 1
0
 public Queue()
 {
     cll = new CircularLinkedList();
 }
Ejemplo n.º 2
0
        private static void testCircularLinkedList()
        {
            CircularLinkedList cll = new CircularLinkedList();

            Console.Out.WriteLine("======>CircularLinkedList Test 1<======");
            Console.Out.WriteLine(">>Tests whether or not the isEmpty method works for any empty CircularLinkedList");
            Console.Out.Write("isEmpty() returned: ");
            Console.Out.WriteLine(cll.isEmpty());
            Console.Out.Write("Test Passed: ");
            Console.Out.WriteLine(cll.isEmpty());
            Console.Out.WriteLine("");

            Console.Out.WriteLine("======>CircularLinkedList Test 2<======");
            Console.Out.WriteLine(">>Tests whether or not the insertAtFront method works, the getSize method works and if the isEmpty method works if the CircularLinkedList has elements");
            cll.insertAtFront("node 1");
            cll.insertAtFront("node 2");
            cll.insertAtFront("node 3");
            Console.Out.Write("isEmpty() (on a CircularLinkedList with elements in it) returned: ");
            Console.Out.WriteLine(cll.isEmpty());
            Console.Out.Write("Test Passed: ");
            Console.Out.WriteLine(cll.isEmpty() == false && cll.getSize() == 3);
            Console.Out.WriteLine("");

            Console.Out.WriteLine("======>CircularLinkedList Test 3<======");
            Console.Out.WriteLine(">>Tests whether or not the getSize and getDataFromBack methods work");
            Console.Out.Write("getSize() returned: ");
            Console.Out.WriteLine(cll.getSize());
            Console.Out.Write("getDataFromBack() returned: ");
            Console.Out.WriteLine(cll.getDataFromBack());
            Console.Out.Write("Test Passed: ");
            Console.Out.WriteLine(String.Equals(cll.getDataFromBack(), "node 1"));
            Console.Out.WriteLine("");

            Console.Out.WriteLine("======>CircularLinkedList Test 4<======");
            Console.Out.WriteLine(">>Tests whether or not the deleteFromBack method worksand if the isEmpty method works on a CircularLinkedList that has had elements but all the elements have been deleted");
            cll.deleteFromBack();
            cll.deleteFromBack();
            cll.deleteFromBack();
            Console.Out.Write("isEmpty() (on a CircularLinkedList with elements in it) returned: ");
            Console.Out.WriteLine(cll.isEmpty());
            Console.Out.Write("Test Passed: ");
            Console.Out.WriteLine(cll.isEmpty());
            Console.Out.WriteLine("");
        }