static void Main(string[] args) { Bandmaster master = new Bandmaster(); Random r = new Random(); OrchestraPlayer[] yama = new OrchestraPlayer[10]; for (int i = 0; i < 10; i++) { int n = r.Next(0, 2); if (n == 0) { yama[i] = new Violinist() { Name = r.Next(1000, 2000).ToString() }; } else { yama[i] = new Hornist() { Name = r.Next(1000, 2000).ToString() }; } master.ev += yama[i].PlayIsStartedEventHandler; } int k = 3; Console.WriteLine("-------"); for (int i = 0; i < k; i++) { master.StartPlay(); Console.WriteLine("-------"); } }
static void Main(string[] args) { Random rnd = new Random; OrchestraPlayer[] orchArray = new OrchestraPlayer[10]; Bandmaster band = new Bandmaster(); for (int i = 0; i < orchArray.Length; i++) { if (rnd.Next(0, 1) == 0) { orchArray[i] = new Violinist(rnd.Next(0, 10000).ToString()); } else { orchArray[i] = new Hornist(rnd.Next(0, 10000).ToString()); } band.Notify += orchArray[i].PlayIsStartedEvent; } band.StartPlay(); }