Ejemplo n.º 1
0
 public void Switch()
 {
     if (channels.GetType() == typeof(TunedChannel))
     {
         int count = 0;
         channels = new RadioChannel();
         foreach (String s in radio)
         {
             channels[count] = radio[count];
             count++;
         }
         iterator = new RadioChannelSelector(channels);
     }
     else
     {
         channels = new TunedChannel();
         int count = 0;
         foreach (String s in tv)
         {
             channels[count] = tv[count];
             count++;
         }
         iterator = new ChannelSelector(channels);
     }
 }
Ejemplo n.º 2
0
        static void IteratorTest()
        {
            IChannelCollection channels     = populateChannels();
            IChannelIterator   baseIterator = channels.iterator(ChannelTypeEnum.ALL);

            while (baseIterator.hasNext())
            {
                Channel c = baseIterator.next();
                Console.WriteLine(c.ToString());
            }
            Console.WriteLine("******");
            // Channel Type Iterator
            IChannelIterator englishIterator = channels.iterator(ChannelTypeEnum.ENGLISH);

            while (englishIterator.hasNext())
            {
                Channel c = englishIterator.next();
                Console.WriteLine(c.ToString());
            }
        }