Beispiel #1
0
        public Game()
        {
            _rules = new Dictionary <Func <int, bool>, Func <int, string> >();
            var fizz     = new Fizz();
            var buzz     = new Buzz();
            var fizzBuzz = new FizzBuzz();

            _rules.Add(fizzBuzz.IsValid, fizzBuzz.GetValue);
            _rules.Add(buzz.IsValid, buzz.GetValue);
            _rules.Add(fizz.IsValid, fizz.GetValue);
        }
Beispiel #2
0
        public static void loop()
        {
            for (int i = 1; i < 100; i++)
            {
                FizzBuzz fb = new FizzBuzz();
                FizzBuzz f  = new Fizz();
                FizzBuzz b  = new Buzz();

                if (i % 5 != 0 && i % 3 != 0 && i % 5 != 0)
                {
                    Console.WriteLine(i);
                }
                else
                {
                    fb.alert(i);
                    f.alert(i);
                    b.alert(i);
                }
            }
        }