示例#1
0
文件: Program.cs 项目: jgonte/FizzBuz
        static void Main(string[] args)
        {
            FizzBuzzProcessor processor = new FizzBuzzProcessor();

            List<object> collection = new List<object>
            {
                "4",
                "word",
                25,
                new
                {
                    name = "Sarah",
                    age = 13
                },
                10
            };

            IList<string> messages = processor.Process(collection, 2, 5);

            Console.WriteLine("Outputting the divisions ...");

            foreach(string message in messages)
            {
                Console.WriteLine(message);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            //setup app
            IFizzBuzzCalculator calculator = new FizzBuzzCalculator();
            IOutput             output     = new Outputter(Console.Out);
            var app = new FizzBuzzProcessor(calculator, output);

            //process collection
            app.ProcessCollection(Enumerable.Range(MinValue, MaxValue));

            //hold screen
            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            int    start, end, fizzNum, buzzNum;
            string fizzAlias, buzzAlias, userFizz, userBuzz;

            bool exit = false;

            do
            {
                fizzNum   = 3;
                buzzNum   = 5;
                fizzAlias = "Fizz";
                buzzAlias = "Buzz";

                Console.WriteLine("Please enter start number: ");

                if (!int.TryParse(Console.ReadLine(), out start))
                {
                    Console.WriteLine("Please enter valid start number");
                    continue;
                }

                Console.WriteLine("Please enter end number: ");

                if (!int.TryParse(Console.ReadLine(), out end))
                {
                    Console.WriteLine("Please enter valid end number");
                    continue;
                }

                Console.WriteLine("Please enter fizz number[3]: ");

                string initFizz = Console.ReadLine();

                if (initFizz != "")
                {
                    if (!int.TryParse(initFizz, out fizzNum))
                    {
                        Console.WriteLine("Please enter valid fizz number");
                        continue;
                    }

                    if (!FizzBuzzProcessor.isPrime(fizzNum))
                    {
                        Console.WriteLine("Please enter only prime num");
                        continue;
                    }
                }

                Console.WriteLine("Please enter buzz number[5]: ");

                string initBuzz = Console.ReadLine();

                if (initBuzz != "")
                {
                    if (!int.TryParse(initBuzz, out buzzNum))
                    {
                        Console.WriteLine("Please enter valid buzz number");
                        continue;
                    }

                    if (!FizzBuzzProcessor.isPrime(buzzNum))
                    {
                        Console.WriteLine("Please enter only prime num");
                        continue;
                    }
                }

                Console.WriteLine("Please enter fizz alias[Fizz]: ");

                userFizz = Console.ReadLine();

                if (userFizz != "")
                {
                    fizzAlias = userFizz;
                }

                Console.WriteLine("Please enter buzz alias[Buzz]: ");

                userBuzz = Console.ReadLine();

                if (userBuzz != "")
                {
                    buzzAlias = userBuzz;
                }

                Console.WriteLine("Please enter to start");

                FizzBuzzProcessor processor = new FizzBuzzProcessor(start, end, fizzNum, buzzNum, fizzAlias, buzzAlias);

                processor.Process();

                Console.WriteLine("Enter E to key to exit or Enter to continue");

                exit = Console.ReadKey().Key == ConsoleKey.E;
            } while (!exit);
        }