Esempio n. 1
0
        static void Main(string[] args)
        {
            var gs = new GermanShepard();

            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[]  // setting the aray
            {
                gs, pg, bh, dp
            };

            foreach (var dog in dogs)    // for each of the idx do below
            {
                Console.WriteLine($"The dog {dog.GetName()} sounds like {dog.Bark()}");
            }
        }
Esempio n. 2
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()}");
                }
            }
        }
Esempio n. 3
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()}");
            }
        }