Guest User

Untitled

a guest
Nov 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 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 nomid
  8. {
  9. class me
  10. {
  11. public int age;
  12. public string name;
  13. public bool grandparents;
  14. public string pet;
  15. public int marks;
  16. public int grands;
  17.  
  18. public me()
  19. {
  20. age = 0;
  21. name = "None";
  22. grandparents = false;
  23. pet = "None";
  24. marks = 0;
  25. About();
  26. }
  27. public me(int age, string name, bool grandparents, string pet)
  28. {
  29. this.age = age;
  30. this.name = name;
  31. this.grandparents = grandparents;
  32. this.pet = pet;
  33. About();
  34. }
  35. public virtual void About()
  36. {
  37.  
  38.  
  39.  
  40. Console.WriteLine("Name: " + name);
  41. Console.WriteLine("Age: " + age);
  42. Console.WriteLine("GrandParents: " + grandparents);
  43. Console.WriteLine("Pet: " + pet);
  44. if (marks <= 1)
  45. {
  46. marks = 2;
  47. }
  48. if (marks > 12)
  49. {
  50. marks = 12;
  51. }
  52. Console.WriteLine("Middle grands: " + marks);
  53. }
  54. public me(int age, string name, bool grandparents,int grands)
  55. {
  56. this.age = age;
  57. this.name = name;
  58. this.grandparents = grandparents;
  59. this.marks = grands;
  60. About();
  61. }
  62.  
  63.  
  64. }
  65. class sister : me
  66. {
  67.  
  68.  
  69.  
  70. public int course;
  71. //private string hi = "А я новый объект класса sister!";
  72. //private string info = "У меня есть аргументы,которые принимаються через класс me";
  73. /*
  74. public sister()
  75. {
  76. About2();
  77. }
  78. */
  79. public override void About()
  80. {
  81. base.About();
  82. Console.WriteLine("Course: " + course);
  83.  
  84. }
  85. public sister(int age,string name,bool grandparents,int grands,int course):base(age, name, grandparents , grands) // Наследование спомощью base
  86. {
  87.  
  88. this.course = course;
  89. About();
  90.  
  91. }
  92.  
  93. /*
  94. public void About2()
  95. {
  96. Console.WriteLine(hi);
  97. Console.WriteLine(info);
  98. Console.WriteLine("Также у меня есть свои аргументы,обьекты." );
  99.  
  100. Console.WriteLine("Course:" + course);
  101. }
  102. */
  103. }
  104. class MyBigClass
  105. {
  106.  
  107. static void Main(string[] args)
  108. {
  109.  
  110. Console.WriteLine("Укажите возраст:");
  111. int x = Convert.ToInt32((Console.ReadLine()));
  112. Console.WriteLine("Укажите имя:");
  113. string x2 = Console.ReadLine();
  114. Console.WriteLine("Укажите вашу середню оценку:");
  115. int x3 = Convert.ToInt32((Console.ReadLine()));
  116. Console.WriteLine("============================================");
  117. me Taras = new me(x,x2, false, x3);
  118. Console.WriteLine("============================================");
  119. //List<me> Dasha = new List<me>();
  120. //Dasha.Add(new sister());
  121. Console.WriteLine("Укажите возраст:");
  122. x = Convert.ToInt16((Console.ReadLine()));
  123. Console.WriteLine("Укажите имя:");
  124. x2 = Console.ReadLine();
  125. Console.WriteLine("Укажите вашу середню оценку:");
  126. x3 = Convert.ToInt16((Console.ReadLine()));
  127. Console.WriteLine("Укажите ваш курс:");
  128. int x4 = Convert.ToInt16((Console.ReadLine()));
  129. sister Dasha = new sister(x, x2, false, x3,x4);
  130. Console.WriteLine("============================================");
  131. Console.ReadKey();
  132.  
  133. }
  134. }
  135. }
  136.  
  137. Укажите возраст:
  138. 10000
  139. Укажите имя:
  140. TozeXz
  141. Укажите вашу середню оценку:
  142. 143
  143. Укажите ваш курс:
  144. 4
  145. Name: TozeXz
  146. Age: 10000
  147. GrandParents: False
  148. Pet:
  149. Middle grands: 12
  150. Course: 0
  151. Name: TozeXz
  152. Age: 10000
  153. GrandParents: False
  154. Pet:
  155. Middle grands: 12
  156. Course: 4
Add Comment
Please, Sign In to add comment