Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement