Пример #1
0
        static void Main(string[] args)
        {
            var boxer1        = new Boxer();
            var pug2          = new Pug("Deadly");
            var gs1           = new GermanShepherd("Killer");
            var germanSheperd = new GermanShepherd("Fred");
            var pug           = new Pug();
            var pug1          = new Pug()



            {
            };
            var dogs = new List <Dog>();

            dogs.Add(pug);
            dogs.Add(germanSheperd);
            dogs.Add(gs1);
            dogs.Add(pug2);
            dogs.Add(boxer1);
            dogs.Add(pug1);


            foreach (var dog in dogs)
            {
                Console.WriteLine(dog.GetTypeDog());
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var germansheperd1 = new GermanShepherd("Killer");

            germansheperd1.LongTail = true;//instance created and now assign value

            var germanSheperd = new GermanShepherd {
                LongTail            = true,
                BarkPitch           = BarkPitchType.Low,
                Muzzle              = MuzzleType.Long,
                ExtremeSenseOfSmell = true,
                BigDog              = true,
                Name = "Fred"
            };

            var pug = new Dog {
                LongTail            = false,
                BarkPitch           = BarkPitchType.High,
                Muzzle              = MuzzleType.Collapsed,
                ExtremeSenseOfSmell = false,
                Name = "Ralph"
            };

            var Barker = new Pug("Barker");
            var pug2   = new Pug();

            var Stan = new Boxer();
            var Sam  = new Boxer("Sam");

            //create a collection of dogs
            //example of polymorphism
            var dogs = new List <Dog>();

            dogs.Add(pug);
            dogs.Add(germanSheperd);
            dogs.Add(germansheperd1);
            dogs.Add(Barker);
            dogs.Add(pug2);
            dogs.Add(Stan);
            dogs.Add(Sam);

            foreach (var dog in dogs)
            {
                Console.WriteLine(dog.GetTypeOfDog());//this just prints Dog
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            var pug1           = new Pug();
            var Boxie          = new Boxer();
            var germanshepherd = new GermanShepherd()
            {
                BarkPitch           = BarkPitch.Low,
                ExtremeSenseOfSmell = true,
                Name = "Killer"
            };
            var pug = new Dog()
            {
                LongTail            = false,
                BarkPitch           = BarkPitch.High,
                Muzzle              = MuzzleType.Collapsed,
                ExtremeSenseOfSmell = false,
                Name = "Ralph"
            };
            var spudsy = new Pug()
            {
                BarkPitch = BarkPitch.High,
                Name      = "Spudsy",
                CurlyTail = true,
                SmallDog  = true
            };

            var ListOfDogs = new List <Dog>();

            ListOfDogs.Add(pug1);
            ListOfDogs.Add(Boxie);
            ListOfDogs.Add(germanshepherd);
            ListOfDogs.Add(pug);
            ListOfDogs.Add(spudsy);
            foreach (var item in ListOfDogs)
            {
                Console.WriteLine(item);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            //Dog dog = new Dog("Pieseł"); // :/

            Dachshund jamnik = new Dachshund("Hot Dog");

            GermanShepherd alex = new GermanShepherd("Komisarz Alex");

            //jamnik.WakeUp();
            //alex.WakeUp();

            //Console.WriteLine("Alex animal: ");
            var alexAnimal = (Animal)alex;

            //alexAnimal.WakeUp();

            alex.Eat();
            jamnik.Eat();
            alexAnimal.Eat();

            alex.FindCat();
            jamnik.FindCat();
        }
Пример #5
0
        static void Main(string[] args)
        {
            var boxer1        = new Boxer();
            var pug1          = new Pug("ThePug");
            var pug2          = new Pug();
            var gs1           = new GermanShepherd("Killer");
            var germanSheperd = new GermanShepherd {
                LongTail            = true,
                BarkPitch           = BarkPitchEnum.Low,
                Muzzle              = MuzzleType.Long,
                ExtremeSenseOfSmell = true,
                BigDog              = false
                                      //,Name = "Fred"
            };
            var pug = new Dog {
                LongTail            = false,
                BarkPitch           = BarkPitchEnum.High,
                Muzzle              = MuzzleType.Collapsed,
                ExtremeSenseOfSmell = false,
                Name = "Ralph"
            };

            var dogs = new List <Dog>();

            dogs.Add(pug);
            dogs.Add(germanSheperd);
            dogs.Add(gs1);
            dogs.Add(pug2);
            dogs.Add(pug1);
            dogs.Add(boxer1);

            foreach (var dog in dogs)
            {
                Console.WriteLine(dog.GetTypeOfDog());
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            var gs1 = new GermanShepherd("Gerald");

            var GermanShepherd = new GermanShepherd {
                BarkPitch = PitchType.Low,
                Name      = "Shep"
            };

            var Pug  = new Pug("Sheldon");
            var Pug2 = new Pug();

            var Doug = new Dog {
                LongTail            = false,
                BarkPitch           = PitchType.High,
                Muzzle              = MuzzleType.Collapsed,
                ExtremeSenseofSmell = false,
                Name = "Doug"
            };

            var Boxer = new Boxer();

            var dogs = new List <Dog>(); //polymorphism example

            dogs.Add(Boxer);
            dogs.Add(Doug);
            dogs.Add(Pug2);
            dogs.Add(Pug);
            dogs.Add(GermanShepherd);
            dogs.Add(gs1);

            foreach (var dog in dogs)
            {
                Console.WriteLine(dog.GetTypeofDog()); //ends example
            }
        }