private DuckFlock CreateTestFlock() { DuckFlock flock = new DuckFlock(); flock.Add(new MallardDuck { Name = "Fred the Mallard" }); flock.Add(new MandarinDuck { Name = "Aaron the Mandarin" }); return flock; }
// Iterator pattern with aggregate void iterateMyDucks_Click(object sender, EventArgs e) { DuckFlock flock = new DuckFlock(); flock.Add(new MallardDuck()); flock.Add(new MandarinDuck()); flock.Add(new RubberDuck()); LoopThroughDucksUsingIterator(flock); }