예제 #1
0
        private static void UseTheMagicHat()
        {
            MagicHat <Rabbit> hat = new MagicHat <Rabbit>();

            hat.Put(new Rabbit {
                Name = "Fluffy"
            });
            hat.Put(new Rabbit {
                Name = "Muffy"
            });

            Rabbit firstRabbit = hat.Pull();

            Console.WriteLine(firstRabbit.Name);
        }
        private static void UseTheMagicHat()
        {
            Console.WriteLine("Abracadabra");

            MagicHat <Rabbit> hat = new MagicHat <Rabbit>();      // instaniate a MagicHat of Rabbit

            hat.Enqueue(new Rabbit {
                Name = "Bugs"
            });                                                 // use the operations inherited Queue<T>
            hat.Enqueue(new Rabbit {
                Name = "Roger"
            });
            hat.Enqueue(new Rabbit {
                Name = "Thumper"
            });

            Rabbit firstRabbit = hat.Dequeue();
        }
예제 #3
0
        private static void UseTheMagicHat()
        {
            MagicHat <Rabbit> rabbitHat = new MagicHat <Rabbit>(); // instaniate a MagicHat of Rabbit

            rabbitHat.Add(new Rabbit {
                Name = "Bugs"
            });
            rabbitHat.Add(new Rabbit {
                Name = "Roger"
            });
            rabbitHat.Add(new Rabbit {
                Name = "Thumper"
            });

            Rabbit firstRabbit = rabbitHat.Retrieve();  // pull rabbit

            Console.WriteLine(firstRabbit.Name);
        }
 public int Add(Rabbit newRabbit)
 {
     return base.Add(newRabbit);
 }
 public int Add(Rabbit newRabbit)
 {
     return(base.Add(newRabbit));
 }