diff --git a/Assessment.h b/Assessment.h new file mode 100644 index 0000000..c0e3f29 --- /dev/null +++ b/Assessment.h @@ -0,0 +1,53 @@ +#ifndef UNIVERSITY_ASSESSMENT_H +#define UNIVERSITY_ASSESSMENT_H +#include + +#include "Teacher.h" +#include "Date.h" + +using namespace std; + +class Assessment { +private: + Teacher *_teacher; + string _subject; + Date *_date; + unsigned int _assessment; + +public: + Assessment(const Teacher* teacher, const string& subject, const Date* date,const unsigned int assessment) + : _subject(subject), _assessment(assessment) { + _teacher = new Teacher(teacher); + _date = new Date(date); + } + + Assessment(const Assessment &assessment) { + _subject = assessment._subject; + _assessment = assessment._assessment; + _date = assessment._date; + _teacher = assessment._teacher; + } + + ~Assessment() { + delete _teacher; + delete _date; + } + + string get_subject() const { + return _subject; + } + + unsigned int get_assessment() const { + return _assessment; + } + + Teacher get_teacher() const { + return *_teacher; + } + + Date get_date() const { + return *_date; + } +}; + +#endif //UNIVERSITY_ASSESSMENT_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f163f8..b8807f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,4 +4,9 @@ project(university) set(CMAKE_CXX_STANDARD 20) add_executable(university main.cpp - Date.h) + Date.h + Person.h + Teacher.h + Student.h + Assessment.h +) diff --git a/Date.h b/Date.h index 9f22a05..da3be90 100644 --- a/Date.h +++ b/Date.h @@ -1,9 +1,11 @@ #ifndef UNIVERSITY_DATE_H #define UNIVERSITY_DATE_H + enum ErrorType { MonthError, DayError }; + enum DAYS { BEGIN_DAY = 1, END_DAY_28 = 28, END_DAY_30 = 30, END_DAY_31 = 31 }; @@ -14,54 +16,54 @@ class Date { unsigned int _month; int _year; - void CheckDay(int day, int end) { + void check_day(int day, int end) { if (day > end || day < DAYS::BEGIN_DAY) { throw ErrorType::DayError; } } public: - void Init(int day, int month, int year) { + Date(unsigned int day, unsigned int month, unsigned int year) { if (month > 12 || month < 1) { throw ErrorType::MonthError; } switch (month) { case 1: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 2: - CheckDay(day, DAYS::END_DAY_28); + check_day(day, DAYS::END_DAY_28); break; case 3: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 4: - CheckDay(day, DAYS::END_DAY_30); + check_day(day, DAYS::END_DAY_30); break; case 5: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 6: - CheckDay(day, DAYS::END_DAY_30); + check_day(day, DAYS::END_DAY_30); break; case 7: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 8: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 9: - CheckDay(day, DAYS::END_DAY_30); + check_day(day, DAYS::END_DAY_30); break; case 10: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; case 11: - CheckDay(day, DAYS::END_DAY_30); + check_day(day, DAYS::END_DAY_30); break; case 12: - CheckDay(day, DAYS::END_DAY_31); + check_day(day, DAYS::END_DAY_31); break; } @@ -69,17 +71,23 @@ class Date { _month = month; _year = year; } - - int GetDay() { + Date(const Date& date) { + _day = date._day; + _month = date._month; + _year = date._year; + } + ~Date() {} = default; + int get_day() { return _day; } - int GetMonth() { + int get_month() { return _month; } - int GetYear() { + + int get_year() { return _year; } }; -#endif //UNIVERSITY_DATE_H \ No newline at end of file +#endif //UNIVERSITY_DATE_H diff --git a/Student.h b/Student.h new file mode 100644 index 0000000..de09287 --- /dev/null +++ b/Student.h @@ -0,0 +1,47 @@ +#ifndef UNIVERSITY_STUDENT_H +#define UNIVERSITY_STUDENT_H +#include +#include + +#include "Person.h" +#include "Assessment.h" +using namespace std; + +class Student : public Person { +private: + string _faculty; + string _group; + vector* _assessments; + +public: + Student(const string& last_name, const string& first_name, Date* date_of_birth, Sex sex, const string& faculty, + const string &group, + const vector *assessments) + : Person(last_name, first_name, date_of_birth, sex), _faculty(faculty), _group(group) { + _assessments = new assessments; + }; + + Student(const Student &student) { + _faculty = student._faculty; + _group = student._group; + _assessments = student._assessments; + } + + + ~Student() { + delete _assessments; + ~Person(); + } + string get_faculty() const { + return _faculty; + } + string get_group() const { + return _group; + } + + vector* get_assessments() const { + return _assessments; + } + +}; +#endif //UNIVERSITY_STUDENT_H diff --git a/Teacher.h b/Teacher.h index 30ed1c2..9be3e3d 100644 --- a/Teacher.h +++ b/Teacher.h @@ -17,7 +17,11 @@ class Teacher : public Person { Teacher(const string& last_name, const string& first_name, Date* date_of_birth, Sex sex, const string& faculty) : Person(last_name, first_name, date_of_birth, sex), _faculty(faculty) { - _subjects = new vector(); + _subjects = new vector; + } + Teacher(const Teacher& teacher):Person(teacher) { + _subjects = teacher._subjects; + _faculty = teacher._faculty; } ~Teacher() { @@ -30,8 +34,8 @@ class Teacher : public Person { _subjects->push_back(subject); } - vector* get_subjects() const { - return _subjects; + vector * get_subjects() const { + return new _subjects; } string get_faculty() const {