Exemple #1
0
        static void Main(string[] args)
        {
            bool userWantsToQuit = false;

            while (!userWantsToQuit)
            {
                Console.WriteLine("Please enter a string and press enter to check if it is a palindrome.");
                Console.WriteLine("If you want to quit type 'quit' and press enter");
                string Input = Console.ReadLine();

                if (Input == "quit")
                {
                    userWantsToQuit = true;
                }

                if (PalindromeCheck.CheckPalindrome(Input))
                {
                    Console.WriteLine("This is a palindrome.");
                }
                else
                {
                    Console.WriteLine("This is not a palindrome.");
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            bool UserWantsToQuit    = false;
            bool IgnoreUppercase    = false;
            bool IgnoreSpecialChars = false;

            while (!UserWantsToQuit)
            {
                Console.WriteLine("Please enter a string and press enter to check if it is a palindrome.");
                Console.WriteLine("If you want to quit type 'quit' and press enter");
                Console.WriteLine("To configure the patterns type in 'config'");

                string Input = Console.ReadLine();

                if (Input == "quit")
                {
                    UserWantsToQuit = true;
                }
                if (Input == "config")
                {
                    Console.WriteLine("Do you want to ignore uppercase? y/n");
                    IgnoreUppercase = (Console.ReadLine().ToLower() == "y") ? true : false;
                    Console.WriteLine("Do you want to ignore special characters? y/n");
                    IgnoreSpecialChars = (Console.ReadLine().ToLower() == "y") ? true : false;
                    Console.WriteLine("Please enter a string and press enter to check if it is a palindrome.");
                    Input = Console.ReadLine();
                }

                Console.WriteLine("---");
                if (PalindromeCheck.CheckPalindrome(Input, IgnoreUppercase, IgnoreSpecialChars))
                {
                    Console.WriteLine("{0} is a palindrome.", Input);
                }
                else
                {
                    Console.WriteLine("{0} is not a palindrome.", Input);
                }
                Console.WriteLine("---");
            }
        }