From 7ca9f83c329f50bfe8c9507f053f75b214b60081 Mon Sep 17 00:00:00 2001 From: y-syo Date: Tue, 19 Aug 2025 17:25:50 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip:?= =?UTF-8?q?=20work=20in=20progress,=20not=20done=20yet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex00/BitcoinExchange.cpp | 87 ++ ex00/BitcoinExchange.hpp | 40 + ex00/Makefile | 58 ++ ex00/data.csv | 1613 ++++++++++++++++++++++++++++++++++++++ ex00/main.cpp | 7 + ex00/obj/main.o | Bin 0 -> 2040 bytes 6 files changed, 1805 insertions(+) create mode 100644 ex00/BitcoinExchange.cpp create mode 100644 ex00/BitcoinExchange.hpp create mode 100644 ex00/Makefile create mode 100644 ex00/data.csv create mode 100644 ex00/main.cpp create mode 100644 ex00/obj/main.o diff --git a/ex00/BitcoinExchange.cpp b/ex00/BitcoinExchange.cpp new file mode 100644 index 0000000..8c1aa2c --- /dev/null +++ b/ex00/BitcoinExchange.cpp @@ -0,0 +1,87 @@ +#include "BitcoinExchange.hpp" + +Date::Date(void) +{ +} + +Date::Date(const std::string str) +{ + // check format (4 char & isdigit into dash into 2 char isdigit & < 1 && isdigit & < 2, and same for day except ahah funny cuz 30 and 31 and 28 and 29 agfjasfgfjahkfga) + + for (std::string::iterator it = str.begin(); it < str.end(); ++it) + { + if (*it != '-') + continue ; + _value *= 10; + _value += *it - '0'; + } +} + +Date::Date(const Date &other) +{ + this->_value = other._value; +} + +Date &Date::operator=(const Date &other) +{ + this->_value = other._value; + return *this; +} + +Date::~Date(void) +{ +} + +bool Date::operator==(const Date &other) const +{ + return this->_value == other._value; +} + +bool Date::operator!=(const Date &other) const +{ + return this->_value != other._value; +} + +bool Date::operator<(const Date &other) const +{ + return this->_value < other._value; +} + +bool Date::operator>(const Date &other) const +{ + return this->_value > other._value; +} + +bool Date::operator<=(const Date &other) const +{ + return this->_value <= other._value; +} + +bool Date::operator>=(const Date &other) const +{ + return this->_value >= other._value; +} + +// --------------------------------------------------- // + +void parseData(const std::string filename) +{ + (void) filename; +} + +void str(std::string input) +{ + input = "2024-10-04 | 135.00\n2014-04-14 | 24.00\n2001-09-11 | 135.00" + std::stringstream input_ss(input); + std::string line; + + while (std::getline(input_ss, line)) + { + std::stringstream ss(input); + std::string date_str; + std::string value_str; + if (!std::getline(ss, date_str, '|') || !std::getline(ss, value_str, '|')) + throw ; //add exception ig + this->_data.insert(std::pair{Date(date_str), std::atoi(value_str.c_str())}); + } +} diff --git a/ex00/BitcoinExchange.hpp b/ex00/BitcoinExchange.hpp new file mode 100644 index 0000000..c0cb495 --- /dev/null +++ b/ex00/BitcoinExchange.hpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +class Date { +public: + Date(void); + Date(const std::string); + Date(const Date &); + Date &operator=(const Date &); + ~Date(void); + + bool operator==(const Date &) const; + bool operator!=(const Date &) const; + + bool operator<(const Date &) const; + bool operator>(const Date &) const; + + bool operator<=(const Date &) const; + bool operator>=(const Date &) const; + +private: + unsigned long long _value; +}; + +class BitcoinExchange { +public: + BitcoinExchange(void) {parseData("data.csv");} + BitcoinExchange(const BitcoinExchange &other) {this->_data = other._data;} + BitcoinExchange &operator=(const BitcoinExchange &other) {this->_data = other._data; return *this;} + ~BitcoinExchange(void) {} + + void parseData(const std::string filename); + void str(std::string input); + +private: + std::map _data; +}; diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..711aa9f --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,58 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: mmoussou 3UVi&Sb}pF(W&gz0?T27lb&j7bPCv7Kv6m zaq3v_kxgpoH1QZf4%5V7`dM;n;IKylWWskDJYfhE`>%EUcfb?+F|mIp^n>b#H$?V` zU+uW>B@s!H5_#9sbWQ9SPusjzRoUtwW4xJ)Y-Wgy(Mz zYFzWk-$#SoU)vo$d zxvp9ha%q0S&s7~ymXv2+oFmWG>~ymmKLy_K&6Y2WvQw*>wlAbCx0F;wR>@de@QXPq zs}42@d@Z?RIVEMurgCM#8YR!uWgwN|`O5Vhbs=YqHzp^FQhJS&oRc+GwT*JUE}#g* zc6`&AonIWK@bUv;SXQ$pRi#3=aYbh{SLJ?Z^sBryE ze literal 0 HcmV?d00001