Animal.cs 847 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApp2
  7. {
  8. class Animal
  9. {
  10. public virtual void sound()
  11. {
  12. Console.WriteLine("make a sound.....");
  13. }
  14. }
  15. class Dog : Animal
  16. {
  17. public override void sound()
  18. {
  19. base.sound();
  20. Console.WriteLine("wangwangwang......");
  21. }
  22. }
  23. interface sound
  24. {
  25. void makeSound();
  26. }
  27. interface eat
  28. {
  29. void food();
  30. }
  31. class Cat : sound,eat
  32. {
  33. public void makeSound()
  34. {
  35. Console.WriteLine("miaomiaomiao.....");
  36. }
  37. public void food()
  38. {
  39. Console.WriteLine("eat cat food...");
  40. }
  41. }
  42. }