Compare commits
3 Commits
79a6afc2b5
...
763bc1c53e
Author | SHA1 | Date | |
---|---|---|---|
|
763bc1c53e | ||
|
6bfaa038a7 | ||
|
641795f36f |
62
Aufg8/ProductSale.cpp
Normal file
62
Aufg8/ProductSale.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
//
|
||||||
|
// Created by DH10MBO on 21.11.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ProductSale.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "../Aufg4/CrimeStats.h"
|
||||||
|
|
||||||
|
ProductSale::ProductSale(std::string line) {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
split(line, ',', result);
|
||||||
|
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 0: region = result[0]; break;
|
||||||
|
case 1: country = result[1]; break;
|
||||||
|
case 2: itemType = result[2]; break;
|
||||||
|
case 3: salesChannel = result[3]; break;
|
||||||
|
case 4: orderPriority = result[4]; break;
|
||||||
|
case 5: orderDate = result[5]; break;
|
||||||
|
case 6: orderId = result[6]; break;
|
||||||
|
case 7: shipDate = result[7]; break;
|
||||||
|
case 8: unitsSold = round(std::stoi(result[8])*100)/100; break;
|
||||||
|
case 9: unitPrice = round(std::stod(result[9])*100)/100; break;
|
||||||
|
case 10:unitCost = round(std::stod(result[10])*100)/100; break;
|
||||||
|
case 11:totalRevenue = round(std::stod(result[11])*100)/100; break;
|
||||||
|
case 12:totalCost = round(std::stod(result[12])*100)/100; break;
|
||||||
|
case 13:totalProfit = round(std::stod(result[13])*100)/100; break;
|
||||||
|
default:
|
||||||
|
std::cout << "I should not be able to reach, the line probably contains to many items" << std::endl;
|
||||||
|
std::cout << line << std::endl;
|
||||||
|
std::cout << "=========================" << std::endl << result[i] << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ProductSale::toString() {
|
||||||
|
std::ostringstream content;
|
||||||
|
|
||||||
|
content
|
||||||
|
<< "region : " << region << std::endl
|
||||||
|
<< "country : " << country << std::endl
|
||||||
|
<< "itemType : " << itemType << std::endl
|
||||||
|
<< "salesChannel : " << salesChannel << std::endl
|
||||||
|
<< "orderPriority : " << orderPriority << std::endl
|
||||||
|
<< "orderDate : " << orderDate << std::endl
|
||||||
|
<< "orderId : " << orderId << std::endl
|
||||||
|
<< "shipDate : " << shipDate << std::endl
|
||||||
|
<< "unitsSold : " << unitsSold << std::endl
|
||||||
|
<< "unitPrice : " << unitPrice << std::endl
|
||||||
|
<< "unitCost : " << unitCost << std::endl
|
||||||
|
<< "totalRevenue : " << totalRevenue << std::endl
|
||||||
|
<< "totalCost : " << totalCost << std::endl
|
||||||
|
<< "totalProfit : " << totalProfit;
|
||||||
|
|
||||||
|
return content.str();
|
||||||
|
}
|
33
Aufg8/ProductSale.h
Normal file
33
Aufg8/ProductSale.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// Created by DH10MBO on 21.11.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef PRODUCTSALE_H
|
||||||
|
#define PRODUCTSALE_H
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
class ProductSale {
|
||||||
|
private:
|
||||||
|
std::string region;
|
||||||
|
std::string country;
|
||||||
|
std::string itemType;
|
||||||
|
std::string salesChannel;
|
||||||
|
std::string orderPriority;
|
||||||
|
std::string orderDate;
|
||||||
|
std::string orderId;
|
||||||
|
std::string shipDate;
|
||||||
|
int unitsSold;
|
||||||
|
double unitPrice;
|
||||||
|
double unitCost;
|
||||||
|
double totalRevenue;
|
||||||
|
double totalCost;
|
||||||
|
double totalProfit;
|
||||||
|
public:
|
||||||
|
ProductSale(std::string line);
|
||||||
|
std::string toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //PRODUCTSALE_H
|
Loading…
Reference in New Issue
Block a user