Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 09 / task1 (not finished) / Student.cpp
diff options
context:
space:
mode:
Commit00b22d8682827a6e8d0098437559537a04236aa4 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2021-04-26 01:11:36 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2021-04-26 01:11:36 +0300
Filesbbb283de3d85882b257bb2bb2acb39e18dc991b8 /Sem. 09/task1 (not finished)/Student.cpp
Object-oriented_programming_FMI-00b22d8682827a6e8d0098437559537a04236aa4.tar
Object-oriented_programming_FMI-00b22d8682827a6e8d0098437559537a04236aa4.tar.gz
Object-oriented_programming_FMI-00b22d8682827a6e8d0098437559537a04236aa4.zip
Parent7ae68dd627bdb2681dc8ddf7c35e415fad8ea814 (diff)
sem 9/10
1 files changed, 45 insertions, 0 deletions
-rw-r--r--Sem. 09/task1 (not finished)/Student.cpp45
diff --git a/Sem. 09/task1 (not finished)/Student.cpp b/Sem. 09/task1 (not finished)/Student.cpp
new file mode 100644
index 0000000..99d26dc
--- /dev/null
+++ b/Sem. 09/task1 (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