Use Big File
This commit is contained in:
parent
e6fedd165e
commit
dbdd4ade8e
@ -29,6 +29,13 @@ std::string readFile(std::string &fileName, std::vector<ProductSale*> &allSales)
|
|||||||
return content;
|
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) {
|
void deleteAllPointers(std::vector<ProductSale*> &allSales) {
|
||||||
for (auto it = allSales.begin(); it != allSales.end(); it++) {
|
for (auto it = allSales.begin(); it != allSales.end(); it++) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
@ -98,7 +105,7 @@ void getOnlineVsOfflineIn(std::string country, std::vector<ProductSale*> &allSal
|
|||||||
|
|
||||||
int OnlineCounter = TypeCounter["Online"];
|
int OnlineCounter = TypeCounter["Online"];
|
||||||
int OfflineCounter = TypeCounter["Offline"];
|
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 << "Online : " << OnlineCounter << std::endl << "Offline : " << OfflineCounter << std::endl;
|
||||||
std::cout << "Ratio : " << ratio << "% Online" << std::endl << 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() {
|
void Aufg8Main() {
|
||||||
std::vector<ProductSale*> allSales;
|
std::vector<ProductSale*> allSales;
|
||||||
std::string fileName = "../Aufg8/IO-Files/sales_records_small.csv";
|
std::string fileName = "../Aufg8/IO-Files/sales_records_small.csv";
|
||||||
|
fileName = "../Aufg8/IO-Files/DANGER-1500000SalesRecords.csv";
|
||||||
|
|
||||||
readFile(fileName, allSales);
|
readFile(fileName, allSales);
|
||||||
|
|
||||||
for (int i = 0; i < allSales.size(); ++i) {
|
// printAllSales(allSales);
|
||||||
std::cout << allSales[i]->toString() << std::endl;
|
|
||||||
std::cout << "==============" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string selectedRegion;
|
std::string selectedRegion;
|
||||||
std::string selectedType;
|
std::string selectedType;
|
||||||
@ -129,19 +134,19 @@ void Aufg8Main() {
|
|||||||
while (currentMenu) {
|
while (currentMenu) {
|
||||||
switch (currentMenu) { // TODO Finish these
|
switch (currentMenu) { // TODO Finish these
|
||||||
case 0:
|
case 0:
|
||||||
return;
|
return; // To quit the programm
|
||||||
case 1:
|
case 1:
|
||||||
// getTotalProfitFor(*selectedType);
|
// getTotalProfitFor(*selectedType);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// getSaleCount(*selectedType, *selectedRegion);
|
// getSaleCount(*selectedType, *selectedRegion);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
getMostPopularTypeIn(selectedRegion, allSales);
|
getMostPopularTypeIn(selectedRegion, allSales);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
getOnlineVsOfflineIn(selectedRegion, allSales);
|
getOnlineVsOfflineIn(selectedRegion, allSales);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout << "You should not be able to reach this!";
|
std::cout << "You should not be able to reach this!";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user