Beispiel #1
0
        private static void TestNDFAClass()
        {
            Automata <String> NDFA1 = TestAutomata.getExampleSlide8Lesson2();
            Automata <String> NDFA2 = TestAutomata.getExampleSlide14Lesson2();

            NDFA1.PrintTransitions();
            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("NDFA1 is dfa? " + NDFA1.IsDfa());
            Console.WriteLine("-----------------------------------------");
            foreach (string state in NDFA1.StartStates)
            {
                Console.WriteLine(state);
            }
            Console.WriteLine("-----------------------------------------");
            foreach (string state in NDFA1.FinalStates)
            {
                Console.WriteLine(state);
            }
            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("String {0} is a {1} string for Auto1.", VALID_STRING_1, NDFA1.IsStringAcceptable(VALID_STRING_1) ? "valid" : "invalid");
            Console.WriteLine("String {0} is a {1} string for Auto1.", INVALID_STRING_0, NDFA1.IsStringAcceptable(INVALID_STRING_0) ? "valid" : "invalid");
            Console.WriteLine("String {0} is a {1} string for Auto1.", VALID_STRING_2, NDFA1.IsStringAcceptable(VALID_STRING_2) ? "valid" : "invalid");
            Console.WriteLine("String {0} is a {1} string for Auto1.", INVALID_STRING_1, NDFA1.IsStringAcceptable(INVALID_STRING_1) ? "valid" : "invalid");
            Console.WriteLine("String {0} is a {1} string for Auto1.", INVALID_STRING_2, NDFA1.IsStringAcceptable(INVALID_STRING_2) ? "valid" : "invalid");
            Console.WriteLine("String {0} is a {1} string for Auto1.", INVALID_STRING_3, NDFA1.IsStringAcceptable(INVALID_STRING_3) ? "valid" : "invalid");
            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("Generate a string of length 9. Resulting string = " + NDFA1.GenerateLanguageOfGivenLength(9));
            Console.WriteLine("-----------------------------------------");

            NDFA2.PrintTransitions();
            Console.WriteLine("NDFA2 is dfa? " + NDFA2.IsDfa());
            Console.WriteLine("-----------------------------------------");
        }