From dbdd4ade8eba5214e2c1b337614e812c62535488 Mon Sep 17 00:00:00 2001 From: Matti Date: Sat, 23 Nov 2024 07:51:26 +0100 Subject: [PATCH] Use Big File --- Aufg8/SalesStatMain.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Aufg8/SalesStatMain.cpp b/Aufg8/SalesStatMain.cpp index 3876781..9f71fa7 100644 --- a/Aufg8/SalesStatMain.cpp +++ b/Aufg8/SalesStatMain.cpp @@ -29,6 +29,13 @@ std::string readFile(std::string &fileName, std::vector &allSales) return content; } +void printAllSales(std::vector &allSales) { + for (int i = 0; i < allSales.size(); ++i) { + std::cout << allSales[i]->toString() << std::endl; + std::cout << "==============" << std::endl; + } +} + void deleteAllPointers(std::vector &allSales) { for (auto it = allSales.begin(); it != allSales.end(); it++) { delete (*it); @@ -98,7 +105,7 @@ void getOnlineVsOfflineIn(std::string country, std::vector &allSal int OnlineCounter = TypeCounter["Online"]; int OfflineCounter = TypeCounter["Offline"]; - double ratio = (OfflineCounter==0) ? 100.0: OnlineCounter/OfflineCounter; + double ratio = (OfflineCounter == 0) ? 100.0 : static_cast(OnlineCounter) / OfflineCounter * 100.0; std::cout << "Online : " << OnlineCounter << std::endl << "Offline : " << OfflineCounter << std::endl; std::cout << "Ratio : " << ratio << "% Online" << std::endl << std::endl; @@ -108,13 +115,11 @@ void getOnlineVsOfflineIn(std::string country, std::vector &allSal void Aufg8Main() { std::vector allSales; std::string fileName = "../Aufg8/IO-Files/sales_records_small.csv"; + fileName = "../Aufg8/IO-Files/DANGER-1500000SalesRecords.csv"; readFile(fileName, allSales); - for (int i = 0; i < allSales.size(); ++i) { - std::cout << allSales[i]->toString() << std::endl; - std::cout << "==============" << std::endl; - } + // printAllSales(allSales); std::string selectedRegion; std::string selectedType; @@ -129,19 +134,19 @@ void Aufg8Main() { while (currentMenu) { switch (currentMenu) { // TODO Finish these case 0: - return; + return; // To quit the programm case 1: // getTotalProfitFor(*selectedType); - break; + break; case 2: // getSaleCount(*selectedType, *selectedRegion); - break; + break; case 3: getMostPopularTypeIn(selectedRegion, allSales); - break; + break; case 4: - getOnlineVsOfflineIn(selectedRegion, allSales); - break; + getOnlineVsOfflineIn(selectedRegion, allSales); + break; default: std::cout << "You should not be able to reach this!"; }