Advertisement
Ne-Biolog

Untitled

May 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. namespace lab5
  6. {
  7. class MainClass
  8. {
  9. public interface IGetInfo
  10. {
  11. void print();
  12. }
  13.  
  14. public enum CourseOfStudy
  15. {
  16. First, Second, Third, Fourth
  17. }
  18.  
  19. public class Person : IComparable<Person>, IGetInfo
  20. {
  21. protected int age;
  22. protected string name, surname;
  23.  
  24. public int CompareTo(Person other)
  25. {
  26. return other.age.CompareTo(this.age);
  27. }
  28.  
  29. public Person(int age, string name, string surname)
  30. {
  31. this.age = age;
  32. this.name = name;
  33. this.surname = surname;
  34. }
  35.  
  36. public virtual void print ()
  37. {
  38. Console.WriteLine("Age = " + age);
  39. Console.WriteLine("Name = " + name);
  40. Console.WriteLine("Surname = " + surname);
  41. }
  42. }
  43.  
  44. public class Student : Person
  45. {
  46. protected CourseOfStudy currCourse;
  47. protected string university;
  48.  
  49. public Student(int age, string name , string surname, CourseOfStudy course, string university)
  50. :base(age, name, surname)
  51. {
  52. this.currCourse = course;
  53. this.university = university;
  54. }
  55.  
  56. public override void print ()
  57. {
  58. base.print();
  59. Console.WriteLine("University = " + university);
  60. Console.WriteLine("Course = " + currCourse);
  61. }
  62. }
  63.  
  64. public class StudentOfCSaN
  65. {
  66. protected string speciality;
  67.  
  68. public StudentOfCSaN(string speciality)
  69. {
  70. this.speciality = speciality;
  71. }
  72.  
  73. public void print()
  74. {
  75. Console.WriteLine("Speciality = " + speciality);
  76. }
  77. }
  78.  
  79. public static void Main(string[] args)
  80. {
  81. List <Person> my = new List<Person>();
  82.  
  83. my.Add(new Person(123, "a", "fdj"));
  84. my.Add(new Person(2223, "b", "fdj"));
  85. my.Add(new Person(1333, "c", "fdj"));
  86. my.Add(new Person(123, "d", "fdj"));
  87.  
  88. my.Sort();
  89.  
  90. foreach(var t in my)
  91. {
  92. t.print();
  93. Console.WriteLine();
  94. }
  95. Console.WriteLine();
  96.  
  97. /*List<Student> my2 = new List<Student>();
  98. my2.Add(new Student(123, "a", "ds", (CourseOfStudy)2, "qew"));
  99. my2.Add(new Student(113, "a", "ds", (CourseOfStudy)2, "qew"));
  100. my2.Add(new Student(13123, "a", "ds", (CourseOfStudy)2, "qew"));
  101. my2.Add(new Student(123333, "a", "ds", (CourseOfStudy)2, "qew"));
  102.  
  103. my2.Sort();
  104. foreach(var t in my2)
  105. {
  106. t.print();
  107. Console.WriteLine();
  108. }*/
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement