Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  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. public enum Education {Specialist, Вachelor, SecondEducation}
  90.  
  91.  
  92.  
  93.  
  94. public class Exam
  95. {
  96. string subject;
  97. int rate;
  98. DateTime examday;
  99. ///////////////
  100. public string Subject
  101. {
  102. get
  103. {
  104. return subject;
  105. }
  106. set {
  107. subject=value;
  108. }
  109.  
  110. }
  111. public int Rate
  112. {
  113. get
  114. {
  115. return rate;
  116. }
  117. set {
  118. rate=value;
  119. }
  120.  
  121. }
  122. ////////////
  123. public DateTime Examday
  124. {
  125. get
  126. {
  127. return examday;
  128. }
  129. set {
  130. examday=value;
  131. }
  132. }
  133.  
  134. public Exam()
  135. {
  136. subject="pract";
  137. rate=5;
  138. examday=new DateTime(2017,05,30);
  139. }
  140.  
  141. public Exam(string sub,int r,DateTime ed)
  142. {
  143. this.subject=sub;
  144. this.rate=r;
  145. this.examday=ed;
  146. }
  147. public override string ToString()
  148. {
  149. return Subject+Rate.ToString()+Examday.ToString();
  150. }
  151.  
  152. }
  153. ///////////////
  154. //////////////
  155. public class Student
  156. {
  157. private Person pers;
  158. private Education fo;
  159. private int gruppa;
  160. private List<Exam> exams;
  161.  
  162.  
  163. /////
  164.  
  165.  
  166. public Person Pers
  167. {
  168. get
  169. {
  170. return pers;
  171. }
  172. set {
  173. pers=value;
  174. }
  175.  
  176. }
  177. public Education Fo
  178. {
  179. get
  180. {
  181. return fo;
  182. }
  183. set {
  184. fo=value;
  185. }
  186.  
  187. }
  188.  
  189.  
  190.  
  191.  
  192.  
  193. List<Exam> Exams
  194. {
  195. get
  196. {
  197. return exams;
  198. }
  199. set
  200. {
  201. exams=value;
  202.  
  203. }
  204. }
  205.  
  206.  
  207. ////////
  208.  
  209. private double sr=0;
  210. public double Sr
  211. {
  212. get
  213. {
  214. int l=exams.Count;
  215. for(int i=1;i<l;i++)
  216. {
  217. sr+=Exams[i].Rate;
  218. }
  219. sr/=l;
  220. return sr;
  221. }
  222. }
  223.  
  224. ///////////
  225.  
  226. public bool this[Education educ ]
  227. {
  228. get
  229. {
  230.  
  231. return educ==fo;
  232. }
  233.  
  234. }
  235.  
  236.  
  237.  
  238.  
  239.  
  240. public void AddExams ( params Exam [] exames)
  241. {
  242. this.exams.AddRange(exames);
  243. }
  244.  
  245.  
  246.  
  247.  
  248. public override string ToString()
  249. {
  250. string s=pers.ToString()+fo.ToString()+gruppa.ToString();
  251. for(int i=1;i<exams.Count;i++)
  252. s+=Exams[i].Subject;
  253.  
  254. return s;
  255. }
  256.  
  257. public virtual string ToShortString()
  258. {
  259. return pers.ToString()+fo.ToString()+gruppa.ToString()+Sr.ToString();
  260. }
  261.  
  262.  
  263. ////////////
  264. public int Gruppa
  265. {
  266. get
  267. {
  268. return gruppa;
  269. }
  270. set {
  271. gruppa=value;
  272. }
  273. }
  274.  
  275. public Student()
  276. {
  277. pers.Birth=new DateTime(1999,11,22);
  278.  
  279. fo=Education.Вachelor;
  280. gruppa=862;
  281. }
  282.  
  283.  
  284.  
  285.  
  286.  
  287. public Student(Person per,Education edu,int g)
  288. {
  289. this.pers=new Person (per.Name,per.SecondName,per.Birth);
  290. this.fo=edu;
  291. this.gruppa=g;
  292. }
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. }
  306.  
  307. public class Program
  308.  
  309. {
  310. public static void Main()
  311. {
  312. Student stud=new Student();
  313. Console.WriteLine(stud.ToShortString());
  314. DateTime d=new DateTime(1999,11,22);
  315. //List<Exam> ex=new List<Exam>();
  316. Console.WriteLine(Education.Specialist+" "+stud[Education.Specialist]);
  317. Console.WriteLine(Education.Вachelor+" "+stud[Education.Вachelor]);
  318. Console.WriteLine(Education.SecondEducation+" "+stud[Education.SecondEducation]);
  319. Console.WriteLine(Education.Specialist+" "+stud[Education.Specialist]);
  320.  
  321.  
  322.  
  323.  
  324. stud.AddExams(new Exam("fdhhd",5,d));
  325. Console.WriteLine(stud.ToString());
  326. stud= new Student(new Person("polya","ivanova",d),Education.Specialist,862);
  327.  
  328.  
  329. Person per= new Person("polya","ivanova",d);
  330. per.Year=2000;
  331. Console.WriteLine(per.Year);
  332. Console.WriteLine(per.ToString());
  333. Console.WriteLine(per.ToShortString());
  334. Education edu=Education.Вachelor;
  335. Console.WriteLine(edu);
  336.  
  337.  
  338. }
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement