commit 7ca9f83c329f50bfe8c9507f053f75b214b60081 Author: y-syo Date: Tue Aug 19 17:25:50 2025 +0200 「🏗️」 wip: work in progress, not done yet. 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