private void Form1_Load(object sender, EventArgs e) { // Заполнение массива Lisboxов for (int i = 2; i < 22; i++) { string str = "listBox" + i; Panel a = this.Controls["panel1"] as Panel; ListBox lb = a.Controls["listBox" + i] as ListBox; lb.Items.Clear(); displays.Add(lb); } listBox1.Items.Add("Creation Started"); // Создание живонтых в зоопарке for (int i = 0; i < displays.Count; i++) { int q = new Random().Next(4); Builder builder = new MammalCreatureBuilder(); // Начало создания животных if (q == 0) { builder = new MammalCreatureBuilder(); //Билдер } if (q == 1) { builder = new BirdCreatureBuilder(); //Билдер } if (q == 2) { builder = new FishCreatureBuilder(); //Билдер } if (q == 3) { builder = new ReptileCreatureBuilder(); //Билдер } Director director = new Director(builder); // Директор director.ConstructRandomCreature(); Creature crt = builder.GetCreature(); // Добавление наблюдателей crt.Attach(new FoodObserver(crt, new Worker())); crt.Attach(new HealthObserver(crt, doctor)); Aviary a = new Aviary(crt, displays[i], i); aviaries.Add(a); a.GetInfo(); // Добавление наблюдателей a.Attach(new UpdateObserver(a)); a.Attach(new ControlTemperatureSystemObserver(a, new Worker())); a.Attach(new MessObserver(a, new Worker())); } listBox1.Items.Add("Creation Successful"); // Начало отсчета времени CurrentTime.Start(); timer1.Start(); }
public ControlTemperatureSystemObserver(Aviary _host, Worker a) { aviary = _host; aviary.Attach(this); worker = a; }
public MessObserver(Aviary _host, Worker a) { aviary = _host; aviary.Attach(this); worker = a; }
public UpdateObserver(Aviary _host) { aviary = _host; aviary.Attach(this); }