public FTestArea() { InitializeComponent(); ta = ClassesP.Iterator.TestArea.getInstance(); iterator = new VolunteerIterator(ta); UpdateIterator(); }
public void UseIterator() { TestArea ta = TestArea.getInstance(); VolunteerIterator it = new VolunteerIterator(ta); Human vl = new Human(ta.Serial(), "Терминатор", "Ятуев", 19, Race.European); ta.AddVolunteer(vl); Assert.AreEqual(it.Last(), vl); }
private void tmrClock_Tick(object sender, EventArgs e) { if (!ta.Empty) { VolunteerIterator iter = new VolunteerIterator(ta); Volunteer member = iter.First(); while (!iter.isDone()) { if (member.HourOfLife()) { Log(member.GetName() + "[id:" + member.ID.ToString() + "] погибает."); ta.RemoveVolunteer(iter.Index); } member = iter.Next(); } UpdateIterator(); } }
private void btnFeed_Click(object sender, EventArgs e) { if (!ckbxAll.Checked) { Output(iterator.Current().Feed()); } else if (!ta.Empty) { VolunteerIterator iter = new VolunteerIterator(ta); Volunteer member = iter.First(); while (!iter.isDone()) { member.Feed(); member = iter.Next(); } Output("Все накормлены."); } }
private void btnRepair_Click(object sender, EventArgs e) { if (!ckbxAll.Checked) { Output(iterator.Current().Repair()); } else if (!ta.Empty) { VolunteerIterator iter = new VolunteerIterator(ta); Volunteer member = iter.First(); while (!iter.isDone()) { member.Repair(); member = iter.Next(); } Output("Все отремонтированы."); } }
protected void UpdateIterator() { iterator.Update(ta); if (ta.Empty) { lblPointer.Text = "0/0"; pnlCommands.Enabled = false; btnDelete.Enabled = false; } else { lblPointer.Text = (iterator.Index + 1).ToString() + "/" + ta.Count.ToString(); pnlCommands.Enabled = true; btnDelete.Enabled = true; } VolunteerIterator iterator2 = new VolunteerIterator(ta, iterator.Index); if (!ta.Empty) { pbCurrent.Image = iterator2.Current().Photo; pbCurrent.Visible = true; } else { pbCurrent.Visible = false; } if (iterator2.isNext()) { pbNext.Image = iterator2.Next().Photo; pbNext.Visible = true; } else { pbNext.Visible = false; } if (iterator2.isNext()) { lblNext2.Visible = true; } else { lblNext2.Visible = false; } iterator2 = new VolunteerIterator(ta, iterator.Index); if (iterator2.isPrev()) { pbPrev.Image = iterator2.Prev().Photo; pbPrev.Visible = true; } else { pbPrev.Visible = false; } if (iterator2.isPrev()) { lblPrev2.Visible = true; } else { lblPrev2.Visible = false; } }