Пример #1
0
 // fields/properties (things mammals all have)
 // name, weight, isFurry
 // methods (things mammals all can do)
 public virtual void Eat(Mammal target)
 {
     Console.WriteLine($"Yum eatting, {target.name}");
     this.weight       += target.weight;
     Mammal.numMammals -= 1;
     target             = null;
 }
Пример #2
0
        static void Main(string[] args)
        {
            IAnimal iAnimalobj = new Animal();
            IAnimal iMammalobj = new Mammal();
            IAnimal iPetobj    = new Pet();
            IAnimal iHumanobj  = new Human();
            IAnimal iCatobj    = new Cat();
            IAnimal iDogobj    = new Dog();
            IAnimal iBirdobj   = new Birds();
            IAnimal iEagleobj  = new Eagle();

            Mammal mHumanobj = new Human();
            Mammal mPetobj   = new Pet();
            Mammal hCatobj   = new Cat();
            Mammal hDogobj   = new Dog();

            Human humanobj = new Human();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Mammal    bear  = new Mammal("Pooh", 23.3, true);
            SeaMammal whale = new SeaMammal(50, "Willie", 2343.3);

            User devon = new User()
            {
                Name = "Devon",
                Age  = 100
            };

            User matt = new User();

            matt.Name = "Matt";
            matt.Age  = 20;


            whale.Eat(bear);


            Console.WriteLine(Mammal.numMammals); // => "Mammal"
        }
Пример #4
0
 public override void Eat(Mammal target)
 {
     // we are totally a separate method
     Console.WriteLine("im a sea mammal eating!!");
     base.Eat(target);
 }