SHARE
TWEET

Untitled

a guest Aug 14th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Correct
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             Animal animal = new Chicken();
  6.             Console.WriteLine(animal.GetCountOfLeg());
  7.             animal = new Dog();
  8.             Console.WriteLine(animal.GetCountOfLeg());
  9.         }
  10.     }
  11.     public abstract class Animal
  12.     {
  13.         public abstract string GetCountOfLeg();
  14.     }
  15.     public class Dog : Animal
  16.     {
  17.         public override string GetCountOfLeg()
  18.         {
  19.             return "4";
  20.         }
  21.     }
  22.     public class Chicken : Dog
  23.     {
  24.         public override string GetCountOfLeg()
  25.         {
  26.             return "2";
  27.         }
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top