Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //create list and add to it
            MyList list = new MyList();

            list.AddToEnd(9);
            list.AddToEnd(2);
            list.AddToBeginning(3);
            list.AddToEnd(6);
            list.Print();
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            MyList list = new MyList();
            list.AddToEnd(10);
            list.AddToEnd(13);
            list.AddToEnd(50);
            list.AddToEnd(67);
            list.AddToEnd(33);
            list.AddToEnd(19);
            list.Print();

        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            MyList list = new MyList();

            list.AddToEnd(9);
            list.AddToEnd(5);
            list.AddToEnd(11);
            list.AddToEnd(4);
            list.AddToBeginning(9);
            list.AddToBeginning(5);
            list.AddToBeginning(11);
            list.AddToBeginning(4);
            list.AddSorted(9);
            list.AddSorted(5);
            list.AddSorted(11);
            list.AddSorted(4);
            list.Print();
        }
 public void ConsolidatedList(MyList list1, MyList list2, MyList list3)
 {
     if (list1.headNode == null && list2.headNode == null)
     {
         return;
     }
     if (list2.headNode == null)
     {
         list3.Print();
     }
     if (list1.headNode != null && list2.headNode != null)
     {
         if (list1.headNode.next == null)
         {
             list2.AddToBeginning(list1.headNode.data);
         }
         else
         {
             list2.AddToBeginning(list1.headNode.data);
             list1.headNode = list1.headNode.next;
             ConsolidatedList(list1, list2, list3);
         }
     }
 }
        static void Main(string[] args)
        {
            MyList list         = new MyList();
            MyList temp         = new MyList();
            MyList tempReversed = new MyList();

            string[] names = new string[]
            {
                "Hasan Minhaj",
                "Nick Jonas",
                "Priyanka Chopra",
                "Angelina Jolie",
                "Varun Dhawan",
                "Zayn Malik",
                "Taylor Swift",
                "Shahrukh Khan",
                "Selena Gomez",
                "Kim Kardashian",
                "Salman Khan",
                "Sonam Kapoor",
                "Kevin Hart",
                "Amitabh Bachchan",
                "Kanye West"
            };

            for (var i = 0; i < names.Length; i++)
            {
                list.AddToEnd(names[i]);
            }
            Console.WriteLine("Hi, Welcome to Tina’s Planning! Here are a few options for the seating arrangement for your event!");
            Console.WriteLine();
            list.Print();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Type the name from the list above following proper letter case who would you like to seat first? ");
            do
            {
                string userInput = Console.ReadLine();
                //validate input
                if (userInput == "")
                {
                    Console.WriteLine("Input cannot be blank");
                }
                else
                {
                    if (userInput != "finish")
                    {
                        temp.AddToBeginning(userInput);
                        tempReversed.AddToEnd(userInput);
                        list.DeleteNode(userInput);
                        Console.WriteLine();
                        Console.WriteLine("Ok, here’s the new arrangement: ");
                        tempReversed.Print();
                        Console.Write(", ");
                        list.Print();
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("Who would you like to seat next? ");
                    }
                    else
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Great! Here is the final seating arrangement: ");
                        list.ConsolidatedList(temp, list, tempReversed);
                        list.Print();
                        Console.WriteLine();
                        Console.WriteLine("The End");
                    }
                }
            }while (true);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            if (args == null) throw new ArgumentNullException(nameof(args));
            var myList = new MyList();

            //myList.AddToEnd(5);
            //myList.AddToEnd(2);
            //myList.AddToEnd(8);
            //myList.AddToEnd(7);
            //myList.AddToEnd(11);

            //myList.AddToBeginning(5);
            //myList.AddToBeginning(2);
            //myList.AddToBeginning(8);
            //myList.AddToBeginning(7);
            //myList.AddToBeginning(11);

            myList.AddSorted(5);
            myList.AddSorted(2);
            myList.AddSorted(8);
            myList.AddSorted(7);
            myList.AddSorted(11);

            myList.Print();

            myList.Find(7);
            myList.Min();
            myList.Max();

            myList.Delete(7);
            myList.Print();

            Console.ReadLine();
        }