aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oop2eindopdr/ZipExport.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/oop2eindopdr/ZipExport.cpp b/oop2eindopdr/ZipExport.cpp
index eb0d60f..3e91256 100644
--- a/oop2eindopdr/ZipExport.cpp
+++ b/oop2eindopdr/ZipExport.cpp
@@ -27,6 +27,7 @@ void ZipExport::export_zip(std::string filename) {
zip_t* zip = zip_open(this->zip_path.c_str(), ZIP_CREATE | ZIP_EXCL, nullptr);
std::string csv_content = "id,value\n";
+ double total_value = 0.f;
for (std::string card_id : this->id_list) {
PokemonCard* card = this->pokedex->get_card_by_id(card_id);
@@ -38,6 +39,7 @@ void ZipExport::export_zip(std::string filename) {
char* value_str;
asprintf(&value_str, "%.2f", card->value);
+ total_value += card->value;
csv_content.append(card->id + "," + std::string(value_str) + "\n");
free(value_str);
@@ -50,6 +52,10 @@ void ZipExport::export_zip(std::string filename) {
zip_file_add(zip, "cards.csv", csv_file, 0);
zip_close(zip);
+
+ char* total_value_str;
+ asprintf(&total_value_str, "%.2f", total_value);
+ std::cout << "sum of market value of cards: " << std::string(total_value_str) << std::endl;
}
void ZipExport::import_csv(std::string filename) {