Advertisement
Guest User

Group.cs

a guest
Mar 28th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. namespace Base
  2. {
  3.     class Group
  4.     {
  5.         public List<Student> Grop;
  6.         public int numgroup, course;
  7.         public Group(List<Student> som)
  8.         {
  9.             Grop = som;
  10.         }
  11.         public void Add(Student a)
  12.         {
  13.             Grop.Add(a);
  14.         }
  15.         public void Del(string z)
  16.         {
  17.             int c = 0;
  18.             foreach (Student n in Grop)
  19.             {
  20.                 bool res = true;
  21.                 if (n.name.Length == z.Length)
  22.                 {
  23.                     for(int i = 0; i <z.Length; i++)
  24.                     {
  25.                         if (n.name[i] != z[i])
  26.                         {
  27.                             res = false;
  28.                         }
  29.                     }
  30.                 }
  31.                 else
  32.                 {
  33.                     res = false;
  34.                 }
  35.                 if (res)
  36.                 {
  37.                     Grop.RemoveAt(c);
  38.                     c--;
  39.                 }
  40.                 c++;
  41.             }
  42.         }
  43.  
  44.         public void showgroup()
  45.         {
  46.             Console.WriteLine("Number of group: {0}. Course: {1}. Size of group: {3}", numgroup, course, Grop.Count());
  47.         }
  48.  
  49.         public void showstudents()
  50.         {
  51.             Console.WriteLine("Student of {0} group: ", numgroup);
  52.             foreach(Student a in Grop)
  53.             {
  54.                 Console.WriteLine("Student {0} {1}, Stud ticket is {2}", a.name, a.surname, a.stnum);
  55.             }
  56.         }
  57.     };
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement