コード例 #1
0
        public AlphabeticalOrderIterator(LuckyCustomers customerCollection, bool reverse = false)
        {
            this._customerCollection = customerCollection;
            this._reverse            = reverse;

            if (reverse)
            {
                this._customerPosition = customerCollection.getItems().Count;
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var collection = new LuckyCustomers();

            collection.AddItem("Jane Doe");
            collection.AddItem("Jack Sparrow");
            collection.AddItem("Adam Smith");

            Console.WriteLine("Straight:");

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }

            Console.WriteLine("\nReverse :");

            collection.ReverseDirection();

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }
        }
コード例 #3
0
        public IteratorPatternStrategy()
        {
            var collection = new LuckyCustomers();

            collection.AddItem("Jane Doe");
            collection.AddItem("Jack Sparrow");
            collection.AddItem("Adam Smith");

            Console.WriteLine("Straight:");

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }

            Console.WriteLine("\nReverse :");

            collection.ReverseDirection();

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }
        }