Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ClassDogger
  8. {
  9. abstract class Dog : IComparable
  10. {
  11. #region Variables
  12. protected string name;
  13. protected int age;
  14. protected double length;
  15. protected double withers;
  16. protected double weight;
  17. protected bool sex;
  18. public abstract double tail();
  19. #endregion
  20.  
  21. #region SetAndGet
  22. public string Name
  23. {
  24. get
  25. {
  26. return name;
  27. }
  28. set
  29. {
  30. name = value;
  31. }
  32. }
  33.  
  34.  
  35. public int Age
  36. {
  37. get
  38. {
  39. return age;
  40. }
  41. set
  42. {
  43. age = value;
  44. }
  45. }
  46.  
  47. public double Length
  48. {
  49. get
  50. {
  51. return length;
  52. }
  53. set
  54. {
  55. length = value;
  56. }
  57. }
  58.  
  59. public double Withers
  60. {
  61. get
  62. {
  63. return withers;
  64. }
  65. set
  66. {
  67. withers = value;
  68. }
  69. }
  70.  
  71. public double Weight
  72. {
  73. get
  74. {
  75. return weight;
  76. }
  77. set
  78. {
  79. weight = value;
  80. }
  81. }
  82.  
  83. public bool Sex
  84. {
  85. get
  86. {
  87. return sex;
  88. }
  89. set
  90. {
  91. sex = value;
  92. }
  93. }
  94. #endregion
  95.  
  96. public Dog(string name, int age, double length, double withers, double weight, bool sex)
  97. {
  98. Name = name;
  99. Age = age;
  100. Length = length;
  101. Withers = withers;
  102. Weight = weight;
  103. Sex = sex;
  104. }
  105.  
  106. #region PrintAll
  107. public void PrintAll()
  108. {
  109. Console.WriteLine("Name: " + name + ", Breed: " + GetType().Name + ", Sex: " + (sex ? "Male" : "Female") + ", Age: " + age + " year(s), Length: " + length + "cm, Withers: " + withers + "cm, Weight: " + weight + "kg, tail length: " + tail() + "cm");
  110. }
  111. #endregion
  112.  
  113. #region EditAll
  114. public void EditAll(string name, int age, double length, double withers, double weigth, bool sex)
  115. {
  116. Name = name;
  117. Age = age;
  118. Length = length;
  119. Withers = withers;
  120. Weight = weight;
  121. Sex = sex;
  122.  
  123. }
  124. #endregion
  125.  
  126. public int CompareTo(object obj)
  127. {
  128. Dog dog = obj as Dog;
  129.  
  130. return String.Compare(Name, dog.Name);
  131. }
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement