Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. using System.IO;
  6.  
  7. namespace K1pvz
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. }
  15. }
  16. class Student
  17. {
  18. string Surname { get; set; }
  19. string Name { get; set; }
  20. string Group { get; set; }
  21.  
  22. private int[] Credits;
  23. private int Capacity;
  24. public int creditCount { get; private set; }
  25.  
  26. public Student(string surname, string name, string group, int capacity=10)
  27. {
  28. this.Surname = surname;
  29. this.Name = name;
  30. this.Group = group;
  31.  
  32. this.Capacity = capacity;
  33. this.Credits = new int[Capacity];
  34. }
  35.  
  36. public void Add(int credit)
  37. {
  38. if (creditCount == Capacity)
  39. {
  40. EnsureCapacity(Capacity * 2);
  41. }
  42. this.Credits[creditCount++] = credit;
  43. }
  44.  
  45. public void Insert(int credit, int index)
  46. {
  47. this.Credits[index] = credit;
  48. }
  49.  
  50. public void RemoveAt(int index)
  51. {
  52. for(int i = index; i < creditCount; i++)
  53. {
  54. Credits[index] = Credits[index - 1];
  55. }
  56. Credits[creditCount] = 0;
  57. }
  58. public void Remove(int item)
  59. {
  60. for(int i = 0; i < creditCount; i++)
  61. {
  62. if (Credits[i] == item)
  63. RemoveAt(i);
  64. }
  65. }
  66. private void EnsureCapacity(int minCapacity)
  67. {
  68. if (minCapacity > Capacity)
  69. {
  70. int[] temp = new int[minCapacity];
  71. for(int i = 0; i < creditCount; i++)
  72. {
  73. temp[i] = Credits[i];
  74. }
  75. Capacity = minCapacity;
  76. Credits = temp;
  77. }
  78. }
  79. }
  80. class Faculty
  81. {
  82. string Name { get; set; }
  83. int CreditCount { get; set; }
  84. int ModuleCount { get; set; }
  85.  
  86. private Student[] students;
  87. private int Capacity;
  88.  
  89. public int studCount { get; private set; }
  90.  
  91. public void Add(Student student)
  92. {
  93. if (studCount == Capacity)
  94. {
  95. EnsureCapacity(Capacity * 2);
  96. }
  97. this.students[studCount++] = student;
  98. }
  99.  
  100. public void Insert(Student student, int index)
  101. {
  102. this.students[index] = student;
  103. }
  104.  
  105. public void RemoveAt(int index)
  106. {
  107. for (int i = index; i < studCount; i++)
  108. {
  109. students[index] = students[index - 1];
  110. }
  111. students[studCount] = null;
  112. }
  113. public void Remove(Student item)
  114. {
  115. for (int i = 0; i < studCount; i++)
  116. {
  117. if (students[i] == item)
  118. RemoveAt(i);
  119. }
  120. }
  121. private void EnsureCapacity(int minCapacity)
  122. {
  123. if (minCapacity > Capacity)
  124. {
  125. Student[] temp = new Student[minCapacity];
  126. for (int i = 0; i < studCount; i++)
  127. {
  128. temp[i] = students[i];
  129. }
  130. Capacity = minCapacity;
  131. students = temp;
  132. }
  133. }
  134. }
  135. class InOutUtils
  136. {
  137. public static Faculty ReadFaculty(string fileName)
  138. {
  139.  
  140. }
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement