Compare commits
2 Commits
68e7176d2e
...
8af59118c2
Author | SHA1 | Date | |
---|---|---|---|
|
8af59118c2 | ||
|
2e4efa7833 |
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
class MenuManager {
|
class MenuManager {
|
||||||
private:
|
private:
|
||||||
int* currentMenu;
|
int * currentMenu;
|
||||||
std::string* selectedMetric;
|
std::string * selectedMetric;
|
||||||
std::string* selectedRegion;
|
std::string * selectedRegion;
|
||||||
public:
|
public:
|
||||||
MenuManager(int* currentMenu, std::string* selectedMetric, std::string* selectedRegion){
|
MenuManager(int * currentMenu, std::string * selectedMetric, std::string * selectedRegion){
|
||||||
this->currentMenu = currentMenu;
|
this->currentMenu = currentMenu;
|
||||||
this->selectedRegion = selectedRegion;
|
this->selectedRegion = selectedRegion;
|
||||||
this->selectedMetric = selectedMetric;
|
this->selectedMetric = selectedMetric;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class ProductSale {
|
class ProductSale {
|
||||||
private:
|
public:
|
||||||
std::string region;
|
std::string region;
|
||||||
std::string country;
|
std::string country;
|
||||||
std::string itemType;
|
std::string itemType;
|
||||||
@ -23,7 +23,7 @@ private:
|
|||||||
double totalRevenue;
|
double totalRevenue;
|
||||||
double totalCost;
|
double totalCost;
|
||||||
double totalProfit;
|
double totalProfit;
|
||||||
public:
|
|
||||||
ProductSale(std::string line);
|
ProductSale(std::string line);
|
||||||
std::string toString();
|
std::string toString();
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -36,10 +37,41 @@ void deleteAllPointers(std::vector<ProductSale*> &allSales) {
|
|||||||
|
|
||||||
void getMostPopularTypeIn(std::string country, std::vector<ProductSale*> &allSales) {
|
void getMostPopularTypeIn(std::string country, std::vector<ProductSale*> &allSales) {
|
||||||
// TODO Add Map DataType
|
// TODO Add Map DataType
|
||||||
for (auto singelSale = allSales.begin(); singelSale != allSales.end(); singelSale++) {
|
std::map<std::string, int>TypeCounter;
|
||||||
|
|
||||||
|
for (ProductSale* singelSale : allSales) {
|
||||||
// map.add(singleSale)
|
// map.add(singleSale)
|
||||||
|
if (singelSale->country != country) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool alreadyExists = false;
|
||||||
|
for (auto element : TypeCounter) {
|
||||||
|
if (element.first == singelSale->itemType) {
|
||||||
|
element.second++;
|
||||||
|
alreadyExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!alreadyExists) {
|
||||||
|
TypeCounter[singelSale->itemType] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return map.getMostCommon
|
// return map.getMostCommon
|
||||||
|
std::string mostPopularType;
|
||||||
|
int counter = 0;
|
||||||
|
for (auto element : TypeCounter) {
|
||||||
|
if (element.second > counter) {
|
||||||
|
counter = element.second;
|
||||||
|
mostPopularType = element.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Most popular Type : " << mostPopularType << std::endl
|
||||||
|
<< "Occurences : " << counter << std::endl << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aufg8Main() {
|
void Aufg8Main() {
|
||||||
@ -53,30 +85,35 @@ void Aufg8Main() {
|
|||||||
std::cout << "==============" << std::endl;
|
std::cout << "==============" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllPointers(allSales);
|
std::string selectedRegion;
|
||||||
|
std::string selectedType;
|
||||||
|
int currentMenu = 0;
|
||||||
|
|
||||||
std::string* selectedRegion;
|
std::string* PselectedRegion = &selectedRegion;
|
||||||
std::string* selectedType;
|
std::string* PselectedType = &selectedType;
|
||||||
int* currentMenu;
|
int* PcurrentMenu = ¤tMenu;
|
||||||
|
|
||||||
MenuManager menu{currentMenu, selectedRegion, selectedType};
|
MenuManager menu{PcurrentMenu, PselectedRegion, PselectedType};
|
||||||
menu.MainInteraction();
|
menu.MainInteraction();
|
||||||
switch (*currentMenu) { // TODO Finish these
|
while (currentMenu) {
|
||||||
case 0:
|
switch (currentMenu) { // TODO Finish these
|
||||||
return;
|
case 0:
|
||||||
case 1:
|
return;
|
||||||
// getTotalProfitFor(*selectedType);
|
case 1:
|
||||||
|
// getTotalProfitFor(*selectedType);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// getSaleCount(*selectedType, *selectedRegion);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
getMostPopularTypeIn(selectedRegion, allSales);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 4:
|
||||||
// getSaleCount(*selectedType, *selectedRegion);
|
// getOnlineVsOfflineIn(*selectedRegion);
|
||||||
break;
|
break;
|
||||||
case 3:
|
default:
|
||||||
getMostPopularTypeIn(*selectedRegion, allSales);
|
std::cout << "You should not be able to reach this!";
|
||||||
break;
|
}
|
||||||
case 4:
|
menu.MainInteraction();
|
||||||
// getOnlineVsOfflineIn(*selectedRegion);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "You should not be able to reach this!";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user