Advertisement
vesso8

Uchebna_disciplina

Jul 9th, 2021
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Subject
  2. {
  3.     char name[20];
  4.     float grade;
  5. public:
  6.     Subject(char *nameIni, int gradeIni) {
  7.         strcpy(name, nameIni);
  8.         grade = gradeIni;
  9.     };
  10. };
  11.  
  12. class Student
  13. {
  14.     char name[15];
  15.     int FN;
  16.     Subject subjects[20];
  17.     int subjectsCount;
  18. public:
  19.     Student(char* nameIni, int FNIni, int countIni) {
  20.         strcpy(name, nameIni);
  21.         FN = FNIni;
  22.         subjectsCount = countIni;
  23.  
  24.     };
  25.     void addGrades(Subject* subjectsIni) {
  26.         for (int i = 0; i < subjectsCount; i++)
  27.         {
  28.             subjects[i] = subjectsIni[i];
  29.         }
  30.     };
  31.     Student& operator=(Student& student) {
  32.         strcpy(this->name, student.name);
  33.         this->FN = student.FN;
  34.         subjectsCount = student.subjectsCount;
  35.         for (int i = 0; i < subjectsCount; i++)
  36.         {
  37.             this->subjects[i] = student.subjects[i];
  38.         }
  39.         return *this;
  40.     };
  41.  
  42. };
  43.  
  44. class Group
  45. {
  46.     int number;
  47.     Student students[26];
  48.     int studentsCount;
  49. public:
  50.     Student(int numberIni, int count) {
  51.         number = numberIni;
  52.         studentsCount = count;
  53.     };
  54.     int addStudent(Student* student) {
  55.         if (studentsCount <= 26) {
  56.             students[studentsCount] = student;
  57.             return 0; // uspeshno dobaven
  58.         }
  59.         return 1; // studentite stavat poveche ot 26
  60.     };
  61. };
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement