示例#1
0
        static void Main(string[] args)
        {
            ICustomCollection <Hero> zone1List = generateZone1();
            ICustomCollection <Hero> zone2List = generateZone2();
            ICustomCollection <Hero> zone3List = generateZone3();

            Console.WriteLine("\n\n--------- First list---------\n\n");

            IEnumerable <Hero> linkedListIterator = new LinkedListIterator(zone1List);

            foreach (var item in linkedListIterator)
            {
                Console.WriteLine($"Name: {item.HeroName}, Class: {item.HeroClass}");
            }

            Console.WriteLine("\n\n--------- Second list---------\n\n");

            IEnumerable <Hero> reversedListIterator = new ReversedArrayListIterator(zone2List);

            foreach (var item in reversedListIterator)
            {
                Console.WriteLine($"Name: {item.HeroName}, Class: {item.HeroClass}");
            }


            Console.WriteLine("\n\n--------- Concatenated list: PvP pairs ---------\n\n");

            var concatenatedList = linkedListIterator.Concat(reversedListIterator);

            /*
             *
             * foreach (var item in concatenatedList)
             * {
             *  foreach(var item2 in concatenatedList)
             *  {
             *      Console.Write($"{{{item.HeroName}, {item2.HeroName}}}\t");
             *  }
             *
             *  Console.WriteLine();
             *  Console.WriteLine();
             * }
             *
             */

            Console.WriteLine("\n\n--------- Concrete hero class linked list ---------\n\n");

            var heroClassIterator = new HeroClassIterator(linkedListIterator, HeroClass.Mage);

            foreach (var item in heroClassIterator)
            {
                Console.WriteLine($"{item.HeroClass} hero: {item.HeroName}");
            }

            Console.WriteLine("\n\n--------- Concrete hero class array list ---------\n\n");

            var heroClassArrayListIterator = new HeroClassIterator(reversedListIterator, HeroClass.Mage);

            foreach (var item in heroClassArrayListIterator)
            {
                Console.WriteLine($"{item.HeroClass} hero: {item.HeroName}");
            }
        }