Example #1
0
        /// <summary>
        /// Övning 4: CheckParanthesis()
        ///
        /// </summary>
        static void CheckParanthesis()
        {
            Console.WriteLine("CheckParanthesis");

            /*
             * Use this method to check if the paranthesis in a string is Correct or incorrect.
             * Example of correct: (()), {}, [({})],  List<int> list = new List<int>() { 1, 2, 3, 4 };
             * Example of incorrect: (()]), [), {[()}],  List<int> list = new List<int>() { 1, 2, 3, 4 );
             */

            CheckParanthesis checkParanthesis = new CheckParanthesis();

            checkParanthesis.RunCheckParanthesis();
        }
        static void CheckParanthesis()
        {
            /*
             * Use this method to check if the paranthesis in a string is Correct or incorrect.
             * Example of correct: (()), {}, [({})],  List<int> list = new List<int>() { 1, 2, 3, 4 };
             * Example of incorrect: (()]), [), {[()}],  List<int> list = new List<int>() { 1, 2, 3, 4 );
             */

            Console.Clear();

            CheckParanthesis checkParanthesis = new CheckParanthesis();
            bool             quit             = false;

            do
            {
                Console.WriteLine("Type '+' to enter Check Paranthesis Mode");
                Console.WriteLine("----------------------------------");
                Console.WriteLine("Type 'Q' to return to Menu");

                char input = InputCheck();

                switch (input)
                {
                case '+':
                    checkParanthesis.isWellFormatted();

                    Console.Clear();
                    break;

                case 'Q':
                    quit = true;

                    Console.Clear();
                    break;

                default:
                    Console.WriteLine("Use '+' followed by a text of your choice");
                    break;
                }
            } while (!quit);
        }