示例#1
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();
        }
示例#2
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();
        }
 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);
        }