Example #1
0
        public static void Main(string[] args)
        {
            Node node1 = new Node("node1");
            Node node2 = new Node("node2");
            Node node3 = new Node("node3");
            Node node4 = new Node("node4");
            Node node5 = new Node("node5");
            LL   LL    = new LL(node1);

            LL.Add(node2);
            LL.Add(node3);
            LL.Add(node4);
            LL.Add(node5);

            Console.WriteLine("BaseLine");
            LL.Print();
            Console.WriteLine("");
            Console.WriteLine("Append to the end");
            Node node6 = new Node("node6");

            LL.Append(node6);
            LL.Print();
            Console.WriteLine("");
            Console.WriteLine("Add before node3");
            Node node7 = new Node("node7");

            LL.AddBefore(node7, node3);
            LL.Print();
            Console.WriteLine("");
            Console.WriteLine("Add after node4");
            Node node8 = new Node("node8");

            LL.AddAfter(node8, node4);
            LL.Print();

            Console.WriteLine(LL.Find("node3"));
        }
Example #2
0
        static void Main( )
        {
            // declare new linked lists
            LL LLofDrugs = new LL( );
            LL emptyList = new LL( );

            // read file, test your Append method
            using (FileStream file = File.Open("RXQT1503.txt", FileMode.Open, FileAccess.Read))
                using (StreamReader reader = new StreamReader(file))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        LLofDrugs.Append(Drug.ParseFileLine(reader.ReadLine( )));
                    }
                }

            LLofDrugs.PrintList();

            // Test your Pop method
            // This 'pops' all nodes in the list one-by-one
            //~ while( LLofDrugs.Pop( ) != null )
            //~ {
            //~ WriteLine();
            //~ LLofDrugs.PrintList();
            //~ }

            // Test the different cases for Remove
            // These should all execute without error when only 10 lines of the file are imported
            //~ LLofDrugs.Remove("AXIRON");
            //~ LLofDrugs.Remove("TRULICITY");
            //~ LLofDrugs.Remove("CYMBALTA");
            //~ LLofDrugs.Remove("IMAGINATION");
            //~ emptyList.Remove("AXIRON");
            //~ WriteLine();
            //~ LLofDrugs.PrintList();
        }