static void PrintReporters(INewspaperIterator iterator) { iterator.First(); while (!iterator.IsDone()) { Console.WriteLine(iterator.Next()); } }
public static void Main(string[] args) { INewspaper nyp = new NyTimesPaper(); INewspaper lap = new LaPaper(); INewspaperIterator nypIterator = nyp.CreateNewspaperIterator(); INewspaperIterator lapIterator = lap.CreateNewspaperIterator(); Console.WriteLine("-------- NYPaper"); PrintReporters(nypIterator); Console.WriteLine("-------- LAPaper"); PrintReporters(lapIterator); Console.ReadLine(); }