Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. public class Person{
  5. private string name1;
  6. private string name2;
  7. private System.DateTime birth;
  8.  
  9. public Person()
  10. {
  11. name1="polya";
  12. name2="ivanova";
  13. birth=new DateTime(1999,11,22);
  14. }
  15.  
  16. public Person(string n1,string n2,DateTime b)
  17. {
  18. this.name1=n1;
  19. this.name2=n2;
  20. this.birth=b;
  21. }
  22. /////////////////
  23. public string Name
  24. {
  25. get
  26. {
  27. return name1;
  28. }
  29. set {
  30. name1=value;
  31. }
  32.  
  33. }
  34. public string SecondName
  35. {
  36. get
  37. {
  38. return name2;
  39. }
  40. set {
  41. name2=value;
  42. }
  43.  
  44. }
  45. ////////////
  46. public DateTime Birth
  47. {
  48. get
  49. {
  50. return birth;
  51. }
  52. set {
  53. birth=value;
  54. }
  55.  
  56. }
  57. public int Year
  58. {
  59. get
  60. {
  61. return birth.Year;
  62. }
  63. set {
  64.  
  65. birth=new DateTime(value,birth.Month,birth.Day);
  66. }
  67. }
  68.  
  69.  
  70. /////////////
  71. public override string ToString()
  72. {
  73.  
  74. return Name+SecondName+Birth.ToString();
  75. }
  76.  
  77.  
  78.  
  79. public virtual string ToShortString()
  80. {
  81.  
  82. return Name+SecondName;
  83. }
  84. }
  85.  
  86.  
  87.  
  88. ////////////////////////////
  89. enum Education {Specialist, Вachelor, SecondEducation}
  90.  
  91. class Exam
  92. {
  93. string subject;
  94. int rate;
  95. DateTime examday;
  96. ///////////////
  97. public string Subject
  98. {
  99. get
  100. {
  101. return subject;
  102. }
  103. set {
  104. subject=value;
  105. }
  106.  
  107. }
  108. public int Rate
  109. {
  110. get
  111. {
  112. return rate;
  113. }
  114. set {
  115. rate=value;
  116. }
  117.  
  118. }
  119. ////////////
  120. public DateTime Examday
  121. {
  122. get
  123. {
  124. return examday;
  125. }
  126. set {
  127. examday=value;
  128. }
  129. }
  130.  
  131. public Exam()
  132. {
  133. subject="pract";
  134. rate=5;
  135. examday=new DateTime(2017,05,30);
  136. }
  137.  
  138. public Exam(string sub,int r,DateTime ed)
  139. {
  140. this.subject=sub;
  141. this.rate=r;
  142. this.examday=ed;
  143. }
  144. public override string ToString()
  145. {
  146. return Subject+Rate.ToString()+Examday.ToString();
  147. }
  148.  
  149. }
  150. ///////////////
  151. //////////////
  152. public class Student
  153. {
  154. private Person pers;
  155. private Education fo;
  156. private int gruppa;
  157. private Exam[] exams;
  158.  
  159.  
  160. /////
  161.  
  162.  
  163.  
  164.  
  165. public Student()
  166. {
  167. pers.Birth=new DateTime(1999,11,22);
  168.  
  169. fo=Education.Вachelor;
  170. gruppa=862;
  171. }
  172.  
  173. public Student(Person per,Education edu,int g)
  174. {
  175. this.pers=per;
  176. this.fo=edu;
  177. this.gruppa=g;
  178. }
  179.  
  180. }
  181.  
  182. public class Program
  183.  
  184. {
  185. public static void Main()
  186. {
  187. DateTime d=new DateTime(1999,11,22);
  188. Person f= new Person("polya","ivanova",d);
  189. f.Year=2000;
  190. Console.WriteLine(f.Year);
  191. Console.WriteLine(f.ToString());
  192. Console.WriteLine(f.ToShortString());
  193.  
  194. }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement