Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Assessment.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef UNIVERSITY_ASSESSMENT_H
#define UNIVERSITY_ASSESSMENT_H
#include <string>

#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
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
46 changes: 27 additions & 19 deletions Date.h
Original file line number Diff line number Diff line change
@@ -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
};
Expand All @@ -14,72 +16,78 @@ 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;
}

_day = day;
_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
#endif //UNIVERSITY_DATE_H
47 changes: 47 additions & 0 deletions Student.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef UNIVERSITY_STUDENT_H
#define UNIVERSITY_STUDENT_H
#include <string>
#include <vector>

#include "Person.h"
#include "Assessment.h"
using namespace std;

class Student : public Person {
private:
string _faculty;
string _group;
vector<Assessment>* _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<Assessment> *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<Assessment>* get_assessments() const {
return _assessments;
}

};
#endif //UNIVERSITY_STUDENT_H
10 changes: 7 additions & 3 deletions Teacher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
_subjects = new vector<string>;
}
Teacher(const Teacher& teacher):Person(teacher) {
_subjects = teacher._subjects;
_faculty = teacher._faculty;
}

~Teacher() {
Expand All @@ -30,8 +34,8 @@ class Teacher : public Person {
_subjects->push_back(subject);
}

vector<string>* get_subjects() const {
return _subjects;
vector <string>* get_subjects() const {
return new _subjects;
}

string get_faculty() const {
Expand Down