Advertisement
Yo_Mb

Yo_21Mb

Oct 13th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. public abstract class Animal
  4. {
  5. private int weight;
  6. private String sound;
  7. public int Weight { get { return weight; } set { weight = value; } }
  8. public String Sound { get { return sound; } set { sound = value; } }
  9. public Animal(int Value)
  10. {
  11. this.Weight = Value;
  12. }
  13. String says()
  14. {
  15. return Sound;
  16. }
  17. }
  18. public class Cow : Animal
  19. {
  20. public Cow(int Value)
  21. {
  22. this.Weight = Value;
  23. }
  24. String says()
  25. {
  26. return Sound = "Mooo";
  27. }
  28. }
  29. public class Snake : Animal
  30. {
  31. public Snake(int Value)
  32. {
  33. this.Weight = Value;
  34. }
  35. String says()
  36. {
  37. return Sound = "Shhh";
  38. }
  39. }
  40. public class Pig : Animal
  41. {
  42. public Pig(int Value)
  43. {
  44. this.Weight = Value;
  45. }
  46. String says()
  47. {
  48. return Sound = "Oink";
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement