uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

commit 2868e9b6e9fbb90efed36461cbe50c98ae339267
parent 16bccc4e7196f0d3ed49325c010728fc73fec71a
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sun, 17 May 2020 02:04:49 +0300

almost finished 2.5

Diffstat:
Massignment-2.4-inheritance/obj/main.o | 0
Massignment-2.5-spreadsheets/bin/spreadsheets | 0
Massignment-2.5-spreadsheets/obj/datahandler.o | 0
Massignment-2.5-spreadsheets/src/datahandler.cpp | 44++++++++++++++++----------------------------
Massignment-2.5-spreadsheets/src/datahandler.h | 10+++-------
5 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/assignment-2.4-inheritance/obj/main.o b/assignment-2.4-inheritance/obj/main.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/bin/spreadsheets b/assignment-2.5-spreadsheets/bin/spreadsheets Binary files differ. diff --git a/assignment-2.5-spreadsheets/obj/datahandler.o b/assignment-2.5-spreadsheets/obj/datahandler.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/src/datahandler.cpp b/assignment-2.5-spreadsheets/src/datahandler.cpp @@ -46,7 +46,8 @@ DataHandler::store_data() lab::getline(f, code, ';'); lab::getline(f, grade); if (f.eof()) break; - if (!analyze(currAM, AM, code, grade)) break; + if (!analyze(currAM, AM, code, + std::atof(grade.cstr()))) break; } } } @@ -65,7 +66,7 @@ DataHandler::analyze( const lab::xstring& currAM, lab::xstring& AM, lab::xstring& code, - lab::xstring& grade) + float grade) { std::map<lab::xstring, Student *>::const_iterator its = studs.find(AM); std::map<lab::xstring, Course *>::const_iterator itc = courses.find(code); @@ -75,12 +76,10 @@ DataHandler::analyze( { data.insert(std::make_pair(studs[currAM], grds)); grds.clear(); - grds.insert(std::make_pair(courses[code], - std::atof(grade.cstr()))); + grds.insert(std::make_pair(courses[code], grade)); return false; } - grds.insert(std::make_pair(courses[code], - std::atof(grade.cstr()))); + grds.insert(std::make_pair(courses[code], grade)); } else if (its == studs.end()) { @@ -95,7 +94,7 @@ DataHandler::analyze( if (its != studs.end() && itc != courses.end()) { - miss(AM, code, std::atof(grade.cstr())); + miss(AM, code, grade); diffr(AM, code, grade); } @@ -131,30 +130,19 @@ DataHandler::miss(lab::xstring AM, lab::xstring code, float grade) } void -DataHandler::diffr(lab::xstring AM, lab::xstring code, const lab::xstring& grade) +DataHandler::diffr(lab::xstring AM, lab::xstring code, float grade) { - float g = std::atof(grade.cstr()); - for (const auto& grd : grds) - if (code == grd.first->get_code() && grd.second != g) - { - errlog.write(ErrLog::ErrType::DIFFERENT_GRADES, - lab::xstring(AM + " in " + code + ": " + - lab::to_xstr<float>("%.1f", grd.second) + " | " + - lab::to_xstr<float>("%.1f", g))); - errcount++; - } -} - -void -DataHandler::dupl( - const lab::xstring& AM, - const lab::xstring& code, - const lab::xstring& grade) -{ - + std::map<Course *, float>::const_iterator it = grds.find(courses[code]); + if (it != grds.end() && it->second != grade) + { + errlog.write(ErrLog::ErrType::DIFFERENT_GRADES, + lab::xstring(AM + " in " + code + ": " + + lab::to_xstr<float>("%.1f", it->second) + " | " + + lab::to_xstr<float>("%.1f", grade))); + errcount++; + } } - bool DataHandler::make_report() const { diff --git a/assignment-2.5-spreadsheets/src/datahandler.h b/assignment-2.5-spreadsheets/src/datahandler.h @@ -22,7 +22,7 @@ class DataHandler std::map<lab::xstring, Student *> studs; std::map<Course *, float> grds; std::map<Student *, std::map<Course *, float>> data; - std::vector<lab::xstring> missing; // bad? + std::vector<lab::xstring> missing; equivalencies eqvs; ErrLog errlog; int misscount, errcount; @@ -41,13 +41,9 @@ class DataHandler const lab::xstring& currAM, lab::xstring& AM, lab::xstring& code, - lab::xstring& grade); + float grade); void miss(lab::xstring AM, lab::xstring code, float grade); - void diffr(lab::xstring AM, lab::xstring code, const lab::xstring& grade); - void dupl( - const lab::xstring& AM, - const lab::xstring& code, - const lab::xstring& grade); + void diffr(lab::xstring AM, lab::xstring code, float grade); bool valid_path(const char *fpath) const; const lab::xstring err_csv (const char *fpath) const; const lab::xstring err_read (const char *fpath) const;