From b9df311eb4e479c150eeb112df91a3ce4dd111ba Mon Sep 17 00:00:00 2001 From: angeld55 Date: Fri, 16 Apr 2021 22:38:37 +0300 Subject: 9 --- Sem. 09/task (not finished)/Student.cpp | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Sem. 09/task (not finished)/Student.cpp (limited to 'Sem. 09/task (not finished)/Student.cpp') diff --git a/Sem. 09/task (not finished)/Student.cpp b/Sem. 09/task (not finished)/Student.cpp new file mode 100644 index 0000000..99d26dc --- /dev/null +++ b/Sem. 09/task (not finished)/Student.cpp @@ -0,0 +1,45 @@ +#include "Student.h" + +Student::Student(const char* name, size_t fn) +{ + setName(name); + setFn(fn); +} + +void Student::setFn(size_t fn) +{ + if (fn < 80000 || fn > 83000) + throw std::exception("Invalid fn"); + + this->fn = fn; +} +void Student::setName(const char* name) +{ + if (strlen(name) > MAX_NAME_LENGTH) + throw std::exception("Name is too long!"); + + strcpy(this->name, name); +} + +size_t Student::getFN() const +{ + return fn; +} +const char* Student::getName() const +{ + return name; +} + +void Student::addGrade(const char* taskName, size_t grade) +{ + if (gradesCount == MAX_GRADES_COUNT) + throw std::exception("Error! Too many grades!"); + + Grade currentGrade(taskName, grade); + grades[gradesCount++] = currentGrade; +} + +void Student::print() const +{ + std::cout << name << " " << fn << std::endl; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d