commit ff36fbf8493141e157bc2467e2471cb403b5fee7 parent dc22358231944047f9d0f0237b62196c4d2c1f1f Author: Christos Margiolis <christos@margiolis.net> Date: Fri, 17 Apr 2020 19:39:52 +0300 changed some var names Diffstat:
16 files changed, 39 insertions(+), 42 deletions(-)
diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/audio.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/audio.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/gameplay.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/gameplay.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/main.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/main.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/minesweeper.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/minesweeper.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/navigation.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/navigation.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/outputs.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/outputs.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/settings.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/settings.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minecurses/obj/wins.o b/assignment-1.5-arrays-pointers-files/minecurses/obj/wins.o Binary files differ. diff --git a/assignment-2.2-classes/classes.cpp b/assignment-2.2-classes/classes.cpp @@ -41,8 +41,6 @@ class Student delete[] this->grades; } - friend std::ostream& operator<< (std::ostream& stream, const Student& s); - inline const char *get_AM() const {return this->AM;} inline const std::string& get_name() const {return this->name;} inline unsigned int get_semester() const {return this->semester;} diff --git a/assignment-2.3-operoverloading/bin/operoverloading b/assignment-2.3-operoverloading/bin/operoverloading Binary files differ. diff --git a/assignment-2.3-operoverloading/obj/main.o b/assignment-2.3-operoverloading/obj/main.o Binary files differ. diff --git a/assignment-2.3-operoverloading/obj/student.o b/assignment-2.3-operoverloading/obj/student.o Binary files differ. diff --git a/assignment-2.3-operoverloading/obj/subject.o b/assignment-2.3-operoverloading/obj/subject.o Binary files differ. diff --git a/assignment-2.3-operoverloading/src/student.cpp b/assignment-2.3-operoverloading/src/student.cpp @@ -3,23 +3,23 @@ Student::Student(const char *AM, const std::string& name) :AM(convert_AM(AM)), name(name), semester(1), psubj(0) { - numSubmittedSubjects = 0; - submittedSubjects = nullptr; + nssubj = 0; + ssubj = nullptr; } Student::Student(const char *AM, const std::string& name, unsigned int semester) :AM(convert_AM(AM)), name(name), semester(semester), psubj(0) { - numSubmittedSubjects = 0; - submittedSubjects = nullptr; + nssubj = 0; + ssubj = nullptr; } Student::Student(const char *AM, const std::string& name, unsigned int semester, unsigned int psubj, const float *grades) :AM(convert_AM(AM)), name(name), semester(semester), psubj(psubj), grades(convert_PSG(grades)) { - numSubmittedSubjects = 0; - submittedSubjects = nullptr; + nssubj = 0; + ssubj = nullptr; } Student::Student(const Student& s) @@ -31,15 +31,15 @@ Student::Student(const Student& s) this->grades = new float[s.psubj]; memcpy(grades, s.grades, sizeof(float) * s.psubj); - if (s.numSubmittedSubjects <= 0) + if (s.nssubj <= 0) { - numSubmittedSubjects = 0; - submittedSubjects = nullptr; + nssubj = 0; + ssubj = nullptr; } else { - this->submittedSubjects = new Subject *[s.numSubmittedSubjects]; - memcpy(submittedSubjects, s.submittedSubjects, sizeof(s.submittedSubjects) * s.numSubmittedSubjects); + this->ssubj = new Subject *[s.nssubj]; + memcpy(ssubj, s.ssubj, sizeof(s.ssubj) * s.nssubj); } } @@ -47,20 +47,20 @@ Student::~Student() { delete[] this->AM; delete[] this->grades; - delete[] this->submittedSubjects; + delete[] this->ssubj; } void Student::operator+= (Subject *s) { - Subject **tmp = new Subject *[numSubmittedSubjects+1]; - if (submittedSubjects != nullptr) + Subject **tmp = new Subject *[nssubj+1]; + if (ssubj != nullptr) { - memcpy(tmp, submittedSubjects, sizeof(Subject *) * numSubmittedSubjects); - delete[] submittedSubjects; + memcpy(tmp, ssubj, sizeof(Subject *) * nssubj); + delete[] ssubj; } - tmp[numSubmittedSubjects] = s; - submittedSubjects = tmp; - numSubmittedSubjects++; + tmp[nssubj] = s; + ssubj = tmp; + nssubj++; } Student Student::operator= (const Student& s) @@ -71,19 +71,19 @@ Student Student::operator= (const Student& s) this->semester = s.semester; this->psubj = s.psubj; if (s.grades != nullptr) this->grades = convert_PSG(s.grades); - if (s.submittedSubjects != nullptr) + if (s.ssubj != nullptr) { - this->numSubmittedSubjects = s.numSubmittedSubjects; - this->submittedSubjects = s.submittedSubjects; + this->nssubj = s.nssubj; + this->ssubj = s.ssubj; } return *this; } -void Student::set_submitted_subjects(Subject **submittedSubjects) +void Student::set_submitted_subjects(Subject **ssubj) { // handle 0 subj - this->submittedSubjects = new Subject *[numSubmittedSubjects]; - memcpy(this->submittedSubjects, submittedSubjects, sizeof(Subject *) * numSubmittedSubjects); + this->ssubj = new Subject *[nssubj]; + memcpy(this->ssubj, ssubj, sizeof(Subject *) * nssubj); } char *Student::convert_AM(const char *AM) diff --git a/assignment-2.3-operoverloading/src/student.h b/assignment-2.3-operoverloading/src/student.h @@ -11,13 +11,13 @@ class Student { private: - char *AM; - std::string name; - Subject **submittedSubjects; - unsigned int numSubmittedSubjects; - unsigned int semester; - unsigned int psubj; - float *grades; + char *AM; // AM + std::string name; // Name + Subject **ssubj; // Submitted subjects + unsigned int nssubj; // Number of submitted subjects + unsigned int semester; // Current semester + unsigned int psubj; // Passed subjects + float *grades; // Grades int size; public: @@ -28,7 +28,6 @@ class Student Student(const Student& s); ~Student(); - friend std::ostream& operator<< (std::ostream& stream, const Student& s); void operator+= (Subject *s); Student operator= (const Student& s); @@ -44,17 +43,17 @@ class Student inline unsigned int get_semester(void) const {return this->semester;} inline unsigned int get_psubj(void) const {return this->psubj;} inline float *get_grades(void) const {return (this->psubj > 0) ? this->grades : nullptr;} - inline Subject **get_submitted_subjects(void) const {return this->submittedSubjects;} - inline unsigned int get_num_submitted_subjects(void) const {return this->numSubmittedSubjects;} + inline Subject **get_submitted_subjects(void) const {return this->ssubj;} + inline unsigned int get_num_submitted_subjects(void) const {return this->nssubj;} inline void set_AM(const char *AM) {this->AM = convert_AM(AM);} inline void set_name(const std::string& name) {this->name = name;} inline void set_semester(unsigned int semester) {this->semester = semester;} inline void set_psubj(unsigned int psubj) {this->psubj = psubj;} inline void set_grades(float *grades) {this->grades = convert_PSG(grades);} - inline void set_num_submitted_subjects(unsigned int numSubmittedSubjects) {this->numSubmittedSubjects = numSubmittedSubjects;} + inline void set_num_submitted_subjects(unsigned int nssubj) {this->nssubj = nssubj;} - void set_submitted_subjects(Subject **submittedSubjects); + void set_submitted_subjects(Subject **ssubj); char *convert_AM(const char *AM); float *convert_PSG(const float *grades); void add_grade(float grade); diff --git a/assignment-2.3-operoverloading/src/subject.h b/assignment-2.3-operoverloading/src/subject.h @@ -7,9 +7,9 @@ class Subject { private: - std::string code; - std::string sname; - unsigned int subjsemester; + std::string code; // Subject code + std::string sname; // Subject name + unsigned int subjsemester; // Corresponding semester of subject public: Subject();