uni

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

commit 82c4af18fa54a2ddabe4c15591d2347d786faff6
parent c643b41f12d4165155427c7a2ad9b025accdc049
Author: Christos Margiolis <christos@margiolis.net>
Date:   Mon,  4 May 2020 21:07:26 +0300

started demonstration in main.cpp

Diffstat:
Massignment-2.4-inheritance/bin/inheritance | 0
Massignment-2.4-inheritance/obj/app.o | 0
Massignment-2.4-inheritance/obj/main.o | 0
Massignment-2.4-inheritance/res/appdata_out.csv | 10+++++-----
Massignment-2.4-inheritance/res/manfdata_out.csv | 4++--
Massignment-2.4-inheritance/res/revs_out.csv | 5+++--
Massignment-2.4-inheritance/src/app.cpp | 3+--
Massignment-2.4-inheritance/src/main.cpp | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
8 files changed, 70 insertions(+), 29 deletions(-)

diff --git a/assignment-2.4-inheritance/bin/inheritance b/assignment-2.4-inheritance/bin/inheritance Binary files differ. diff --git a/assignment-2.4-inheritance/obj/app.o b/assignment-2.4-inheritance/obj/app.o Binary files differ. 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.4-inheritance/res/appdata_out.csv b/assignment-2.4-inheritance/res/appdata_out.csv @@ -1,6 +1,6 @@ Type,SN,Name,OS,Manf,Price,Genre,Online,Extensions -Game,0001,LoL,MAD Robot 4.5,Riot,0,MOBA,Yes,N/A -Game,0002,CS:GO,MAD Robot 3.0,Valve,14,FPS,Yes,N/A -Office,0003,LibreOffice,MAD Robot 2.0,GNU,0,N/A,N/A,.doc|.xls|.odt|.ods|.ppt| -Office,0004,Vim,MAD Robot 1.0,GNU,0,N/A,N/A,.txt|.md|.tex|.cpp|.sh| -Office,0004,OpenOffice,MAD Robot 2.2,Company,0,N/A,N/A,.doc|.xls|.ppt| +Game,0001,LoL,MAD Robot 4.5,Riot,155,MOBA,Yes,N/A +Game,0002,CS:GO,MAD Robot 3.0,Valve,14,Shooter,Yes,N/A +Office,0003,LibreOffice,MAD Robot 2.0,FreeSoftware,0,N/A,N/A,.doc|.xls|.odt|.ods|.ppt| +Office,1254,zathura,MAD Robot 2.2,Company,0,N/A,N/A,.exe|.bin|.dat| +Game,0005,minesweeper,MAD Robot 1.0,Chris,0,Puzzle,Yes,N/A diff --git a/assignment-2.4-inheritance/res/manfdata_out.csv b/assignment-2.4-inheritance/res/manfdata_out.csv @@ -1,6 +1,6 @@ SN,Name,Email -0004,Company,comp@comp.com -0005,Chris,chris@chris.com 0001,Riot,riot@riot.com 0002,Valve,valve@valve.com 0003,GNU,gnu@gnu.com +0004,Company,comp@comp.com +0005,Chris,chris@chris.com diff --git a/assignment-2.4-inheritance/res/revs_out.csv b/assignment-2.4-inheritance/res/revs_out.csv @@ -1,4 +1,5 @@ AppName,Stars,Username,Comment LoL,3,randomuser1,Nice -Vim,4,coolguy,Epic -Vim,5,nerd,Best editor +LibreOffice,2,user1,Not so good +LibreOffice,4,user2,Good app +minesweeper,5,gamer,Good game diff --git a/assignment-2.4-inheritance/src/app.cpp b/assignment-2.4-inheritance/src/app.cpp @@ -32,7 +32,6 @@ App::App(const char *serialnum, const std::string& name, } } -#include <iostream> App::~App() { if (serialnum != nullptr) delete[] serialnum; @@ -94,7 +93,7 @@ int App::get_price() const void App::set_serialnum(const char *serialnum) { - if (this->serialnum != nullptr) delete[] serialnum; + if (this->serialnum != nullptr) delete[] this->serialnum; this->serialnum = convsn(serialnum); } diff --git a/assignment-2.4-inheritance/src/main.cpp b/assignment-2.4-inheritance/src/main.cpp @@ -1,6 +1,33 @@ #include "appsystem.h" #include <iomanip> +std::ostream& operator<< (std::ostream& stream, const AppSystem& sys); +static void cont(); +static void pluseqs(AppSystem& sys); +static void edit(AppSystem& sys); +static void remove(AppSystem& sys); +static void getapps(const AppSystem& sys); + +int main(int argc, char **argv) +{ + AppSystem sys; + if (!sys.import_data<Manufacturer>("res/manfdata.csv")) return -1; + if (!sys.import_data<App>("res/appdata.csv")) return -1; + if (!sys.import_data<Review>("res/revs.csv")) return -1; + + pluseqs(sys); + std::cout << sys << std::endl; + edit(sys); + remove(sys); + getapps(sys); + + if (!sys.export_data<Manufacturer>("res/manfdata_out.csv")) return -1; + if (!sys.export_data<App>("res/appdata_out.csv")) return -1; + if (!sys.export_data<Review>("res/revs_out.csv")) return -1; + + return 0; +} + std::ostream& operator<< (std::ostream& stream, const AppSystem& sys) { stream << @@ -64,35 +91,49 @@ std::ostream& operator<< (std::ostream& stream, const AppSystem& sys) return stream; } -int main(int argc, char **argv) +static void cont() +{ + std::cout << std::endl; + std::cout << "Press <ENTER> to continue. . ."; + if (std::cin.get()) system("clear || cls"); +} + +static void pluseqs(AppSystem& sys) { - AppSystem sys; Manufacturer *comp = new Manufacturer("0004", "Company", "comp@comp.com"); Manufacturer *chris = new Manufacturer("0005", "Chris", "chris@chris.com"); sys += comp; sys += chris; - if (!sys.import_data<Manufacturer>("res/manfdata.csv")) return -1; - if (!sys.import_data<App>("res/appdata.csv")) return -1; - if (!sys.import_data<Review>("res/revs.csv")) return -1; - std::vector<std::string> ext = {".doc", ".xls", ".ppt"}; - sys += new Office("0004", "OpenOffice", "MAD Robot 2.2", comp, 0, ext); + std::vector<std::string> ext = {".pdf", ".md"}; + sys += new Office("0004", "zathura", "MAD Robot 2.2", comp, 0, ext); sys += new Game("0005", "minecurses", "MAD Robot 1.0", chris, 0, "Puzzle", false); +} - sys.newrev("minecurses", new Review(4, "Name Surnaming", "Good")); - std::cout << sys << std::endl; +static void edit(AppSystem& sys) +{ + sys.newrev("minecurses", new Review(5, "gamer", "Good game")); + sys.newrevs("LibreOffice", {new Review(2, "user1", "Not so good"), new Review(4, "user2", "Good app")}); + sys.chserialnum("zathura", "1254"); + sys.chname("minecurses", "minesweeper"); + sys.chos("Vim", "macOS"); + sys.chmanf("LibreOffice", new Manufacturer("0006", "FreeSoftware", "freesoft@freesoft.com")); + sys.chprice("LoL", 155); + sys.chgenre("CS:GO", "Shooter"); + sys.chonline("minesweeper", true); + sys.chexts("zathura", {".exe", ".bin", ".dat"}); +} - sys.removebad(chris); +static void remove(AppSystem& sys) +{ + sys.removebad("GNU"); +} - std::vector<Office *> fapps = sys.get_freeapps(); - std::vector<Game *> ggames = sys.get_goodgames(); +static void getapps(const AppSystem& sys) +{ + const std::vector<Office *>& fapps = sys.get_freeapps(); + const std::vector<Game *>& ggames = sys.get_goodgames(); for (auto& fapp : fapps) std::cout << fapp->get_name() << std::endl; for (auto& ggame : ggames) std::cout << ggame->get_name() << std::endl; - - if (!sys.export_data<Manufacturer>("res/manfdata_out.csv")) return -1; - if (!sys.export_data<App>("res/appdata_out.csv")) return -1; - if (!sys.export_data<Review>("res/revs_out.csv")) return -1; - - return 0; }