Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Clazz clazz = new Clazz();

            clazz.AddStudent(new Student("张三"));
            clazz.AddStudent(new Student("李四"));
            clazz.AddStudent(new Student("王五"));

            Iterator iterator = (clazz as Aggregate).CreateInterator();

            while (!iterator.Done)
            {
                object current = iterator.Current();
                Console.WriteLine(current);
                iterator.Next();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 对班级的依赖
 /// </summary>
 /// <param name="classToInterator"></param>
 public ClazzASCIterator(Clazz classToInterator)
 {
     this.myclass = classToInterator;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 对班级的依赖
 /// </summary>
 /// <param name="classToInterator"></param>
 public ClazzDESCIterator(Clazz classToInterator)
 {
     this.myclass      = classToInterator;
     this.currentIndex = this.myclass._students.Count - 1;
 }