Пример #1
0
 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;
 }
Пример #2
0
 // 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);
 }
Пример #3
0
 private void LoopThroughDucksUsingIterator(DuckFlock flock)
 {
     IIterator<IQuackable> duckIterator = new DuckIterator(flock);
     IQuackable currentDuck = duckIterator.Current();
     while (currentDuck != null)
     {
         currentDuck.Quack();
         currentDuck = duckIterator.Next();
     }
 }
Пример #4
0
 public NameSorter(DuckFlock flockToSort)
 {
     this.flockToSort = flockToSort;
 }