Use Big File

This commit is contained in:
Matti 2024-11-23 07:51:26 +01:00
parent e6fedd165e
commit dbdd4ade8e

View File

@ -29,6 +29,13 @@ std::string readFile(std::string &fileName, std::vector<ProductSale*> &allSales)
return content;
}
void printAllSales(std::vector<ProductSale*> &allSales) {
for (int i = 0; i < allSales.size(); ++i) {
std::cout << allSales[i]->toString() << std::endl;
std::cout << "==============" << std::endl;
}
}
void deleteAllPointers(std::vector<ProductSale*> &allSales) {
for (auto it = allSales.begin(); it != allSales.end(); it++) {
delete (*it);
@ -98,7 +105,7 @@ void getOnlineVsOfflineIn(std::string country, std::vector<ProductSale*> &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<double>(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<ProductSale*> &allSal
void Aufg8Main() {
std::vector<ProductSale*> 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!";
}