static void Main()             //入口方法
    {
        Car c = new BM();          //创建BM对象

        c.Name  = "宝马";            //为Name字段赋值
        c.Color = "红色";            //为Color属性赋值
        c.show();                  //执行show()方法
        c.Run();                   //执行Run()方法
        c.Stop();                  //执行Stop()方法
        System.Console.ReadLine(); //等待回车继续
    }
        static void Main(string[] args)
        {
            Logger.WriteLine("String Pattern Matching");

            // Variable to hold whether or not to continue the program after each termination
            string keepPlaying;

            // Loop while the user wants to continue
            do
            {
                // Get user input of text, pattern, and which algorithm to run
                var(text, pattern, algorithm) = GetUserInput();

                // Run one algorithm if user did not specify to run all
                if (algorithm != "all" && algorithm != "ALL")
                {
                    // Get the index and comparisons based on which algorithm the user chose
                    var(index, comparisons) = algorithm switch
                    {
                        var x when x == "BF" || x == "bf" => BruteForce.Run(text, pattern),
                        var y when y == "BMH" || y == "bmh" => BMH.Run(text, pattern),
                        var z when z == "BM" || z == "bm" => BM.Run(text, pattern),
                        _ => throw new Exception("Invalid algorithm string"),
                    };

                    // If the pattern was not found
                    if (index == -1)
                    {
                        Logger.Write("\nPattern was not found in the given text. ");
                    }
                    // Else the pattern was found
                    else
                    {
                        Logger.Write($"\nPattern was found at index {index}. ");
                    }

                    Logger.WriteLine($"There were {comparisons} comparisons made.");
                }
                else
                {
                    // Get the index and comparisons from all algorithms
                    var(indexBF, comparisonsBF)   = BruteForce.Run(text, pattern);
                    var(indexBMH, comparisonsBMH) = BMH.Run(text, pattern);
                    var(indexBM, comparisonsBM)   = BM.Run(text, pattern);

                    // All algorithms should return the same index so we only need to use indexBF

                    // If pattern was not found
                    if (indexBF == -1)
                    {
                        Logger.WriteLine("\nPattern was not found in the given text. ");
                    }
                    // Else pattern was found
                    else
                    {
                        Logger.WriteLine($"\nPattern was found at index {indexBF}. ");
                    }

                    Logger.WriteLine($"There were {comparisonsBF} comparisons made by the Brute Force Algorithm.");
                    Logger.WriteLine($"There were {comparisonsBMH} comparisons made by the Boyer-Moore-Horspool Algorithm.");
                    Logger.WriteLine($"There were {comparisonsBM} comparisons made by the Boyer-Moore Algorithm.");
                }

                // Loop until valid input of y/n
                do
                {
                    Logger.WriteLine("\nWould you like to repeat program? y/n ");
                    keepPlaying = Logger.ReadLine();
                }while (keepPlaying != "y" && keepPlaying != "Y" && keepPlaying != "n" && keepPlaying != "N");

                Logger.WriteLine();
            }while (keepPlaying == "y" || keepPlaying == "Y");

            Logger.LogToFile();

            Console.WriteLine("\nLog outputted to logs/ directory.");

            Console.WriteLine("\nPress enter to exit...");
            Console.ReadLine();
        }