static void Main(string[] args)
        {
            Bandmaster master = new Bandmaster();
            Random     rng    = new Random();

            OrchestraPlayer[] arr = new OrchestraPlayer[10];
            for (int i = 0; i < 10; i++)
            {
                if (rng.Next(0, 2) % 2 == 0)
                {
                    arr[i] = new Violinist()
                    {
                        Name = "# " + rng.Next(1, 101).ToString()
                    };
                }
                else
                {
                    arr[i] = new Hornist()
                    {
                        Name = "# " + rng.Next(1, 101).ToString()
                    };
                }
                master.ev += arr[i].PlayIsStartedEventArgs;
            }
            Console.WriteLine("*******************************************");
            master.StartPlay();
        }
        static void Main(string[] args)
        {
            Bandmaster mas = new Bandmaster();
            Random     r   = new Random();

            OrchestraPlayer[] players = new OrchestraPlayer[5];
            for (int i = 0; i < players.Length; i++)
            {
                if (r.Next(0, 2) == 0)
                {
                    players[i] = new Violinist()
                    {
                        Name = r.Next(100, 900).ToString()
                    }
                }
                ;
                else
                {
                    players[i] = new Hornist()
                    {
                        Name = r.Next(100, 900).ToString()
                    }
                };
                mas.ev += players[i].PlayIsStatedEventHandler;
            }
            mas.StartPlay();
        }
    }
Exemple #3
0
        static void Main(string[] args)
        {
            Random     random     = new Random();
            Bandmaster bandmaster = new Bandmaster();

            OrchestraPlayer[] orchestraPlayers = new OrchestraPlayer[10];
            for (int i = 0; i < 10; i++)
            {
                switch (random.Next(0, 2))
                {
                case 0:
                    orchestraPlayers[i] = new Violinist(random.Next(10).ToString());
                    break;

                case 1:
                    orchestraPlayers[i] = new Hornist(random.Next(10).ToString());
                    break;
                }
                bandmaster.PlayIsStartedEvent += orchestraPlayers[i].PlayIsStartedEventHandler;
            }
            try
            {
                int number = int.Parse(Console.ReadLine());
                for (int i = 0; i < number; i++)
                {
                    bandmaster.StartPlay(random.Next(10));
                }
            }
            catch
            {
                Console.WriteLine("Ошибка");
            }
            Console.ReadKey();
        }