Example #1
0
        static void Main(string[] args)
        {
            {
                var gs = new GermanShepherd();
                gs.SetName("Arlo");

                var p = new Pug();
                p.SetName("daisy");

                var bs = new BassetHound();
                bs.SetName("Charles");

                var dp = new DogParrot();
                dp.SetName("Flap");

                var dogs = new IBarkAble[]
                {
                    gs, p, bs, dp
                };

                foreach (var dog in dogs)
                {
                    Console.WriteLine($"The  dog {dog.GetName()} says {dog.Bark()}");
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var gs = new GermanShepherd();

            gs.SetName("Sargent");
            var pg = new Pug();

            pg.SetName("Walter");
            var bh = new BassetHound();

            bh.SetName("Charlie");
            var dp = new DogParrot();

            dp.SetName("Polly");

            var dogs = new IBarkable[] {
                gs, pg, bh, dp
            };

            foreach (var dog in dogs)
            {
                Console.WriteLine($"the dog {dog.GetName()} says {dog.Bark()}");
            }
        }