コード例 #1
0
        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);
        }