コード例 #1
0
        public static void InvokeObserve()
        {
            IObservador observer = new Observador();
            Apostador   cleber   = new Apostador("Cthulhu", observer, 10000);
            Apostador   koba     = new Apostador("Kobayashi", observer, 10000);
            Apostador   jimmy    = new Apostador("Jimmy", observer, 10000);

            observer.add(cleber);
            observer.add(koba);
            observer.add(jimmy);

            int    max = 0;
            Random rnd = new Random();

            while (max < 3)
            {
                max = 0;

                int bet = rnd.Next(11000);
                if (bet > cleber.lastBet)
                {
                    cleber.sendMessage(bet);
                }


                bet = rnd.Next(11000);
                if (bet > koba.lastBet)
                {
                    koba.sendMessage(bet);
                }

                bet = rnd.Next(11000);
                if (bet > jimmy.lastBet)
                {
                    jimmy.sendMessage(bet);
                }

                if (cleber.maxBet <= cleber.lastBet)
                {
                    max++;
                }
                if (koba.maxBet <= bet)
                {
                    max++;
                }
                if (jimmy.maxBet <= bet)
                {
                    max++;
                }
            }

            Console.WriteLine(jimmy.lastPutter + " " + cleber.lastBet);
            Console.WriteLine(koba.lastPutter + " " + cleber.lastBet);

            Console.ReadLine();
        }