Exemple #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()}");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var gs = new GermanShephard();

            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 says {dog.Bark()}");
                Console.WriteLine($" The dog {dog.GetName()} says {dog.Bark()}");
            }
        }
Exemple #3
0
 public void Execute(IBarkable animal)
 {
     animal.Bark(_cli);
 }