static void Main(string[] args) { CocreteAggregate cocrete = new CocreteAggregate(); cocrete[0] = "张三"; cocrete[1] = "李四"; cocrete[2] = "王五"; cocrete[3] = "赵六"; cocrete[4] = "刘七"; Iterator i = new CocreteIterator(cocrete); i.First(); while (!i.IsDone()) { Console.WriteLine($"{i.CurrentItem().ToString()}的请买票"); i.Next(); } Console.Read(); }
public CocreteIterator(CocreteAggregate cocreteAggregate) { _cocreteAggregate = cocreteAggregate; }