Exemplo n.º 1
0
        static void Main(string[] args)
        {
            object[] arr = { "1", "2", "3", "4", "5", "6" };

            var aggrate = new ConcreteAggrate(arr);

            Console.WriteLine("this is for loop!");

            for (var i = 0; i < aggrate.GetSize(); i++)
            {
                Console.WriteLine(aggrate.GetElement(i));
            }
            Console.WriteLine("this is iterator loop!");

            IIterator iterator = aggrate.GetIterator();

            while (!iterator.IsDone())
            {
                Console.WriteLine(iterator.GetElement());
                iterator.MoveNext()
                ;
            }
            Console.ReadLine();
        }