public void TestCase1()
        {
            var aggregate = new ConcreteAggregate();

            aggregate[0] = "Apple";
            aggregate[1] = "Orange";
            aggregate[2] = "Strawberry";

            var iterator = new ConcreteIterator(aggregate);

            object item = iterator.First();

            while (iterator.IsDone() == false)
            {
                Console.WriteLine(item);
                item = iterator.Next();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ConcreteAggregate a = new ConcreteAggregate();

            a[0] = "Item A";
            a[1] = "Item B";
            a[2] = "Item C";
            a[3] = "Item D";

            ConcreteIterator i = new ConcreteIterator(a);

            Console.WriteLine("Iterating over collection:");
            object item = i.First();

            while (item != null)
            {
                Console.WriteLine(item);
                item = i.Next();
            }

            Console.ReadKey();
        }