diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-12-25 23:03:51 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-12-25 23:03:51 +0100 |
commit | 32f38a285afcf54e83e517e5e46bcff88c0000f6 (patch) | |
tree | 14d9dcd0cb25a291e515b826011e7255e80fdb40 /oop2eindopdr | |
parent | ea5df8bc1c03c51a3e9e2408855811ac1045e399 (diff) |
print sum value
Diffstat (limited to 'oop2eindopdr')
-rw-r--r-- | oop2eindopdr/ZipExport.cpp | 6 |
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) { |