「🔨」 fix: fixed ex00
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/21 10:39:45 by adjoly #+# #+# */
|
||||
/* Updated: 2025/06/30 10:54:14 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/07/03 13:58:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -210,7 +210,7 @@ BitcoinExchange::BitcoinExchange(char *av) : _is(av), _filename(av) {
|
||||
try {
|
||||
_csv = new CsvParser();
|
||||
} catch (std::exception &e) {
|
||||
throw e;
|
||||
throw std::runtime_error("there is a issue with the data.csv");
|
||||
}
|
||||
|
||||
if (!_is.is_open()) {
|
||||
@ -294,18 +294,14 @@ std::pair<Date, float> BitcoinExchange::_parseLine(void) {
|
||||
|
||||
void BitcoinExchange::_printPair(std::pair<Date, float> pair) {
|
||||
auto map = _csv->getCsv();
|
||||
auto it = std::find_if(map.begin(), map.end(), CompareDate(pair.first));
|
||||
if (it == map.end()) {
|
||||
delete _csv;
|
||||
throw std::out_of_range("out of range");
|
||||
auto itDate = map.begin();
|
||||
for (auto it = range(map)) {
|
||||
if (it->first >= pair.first) {
|
||||
break;
|
||||
}
|
||||
itDate = it;
|
||||
}
|
||||
|
||||
float i = it->second * pair.second;
|
||||
float i = itDate->second * pair.second;
|
||||
std::cout << pair.first << " => " << pair.second << " = " << i << std::endl;
|
||||
}
|
||||
|
||||
CompareDate::CompareDate(Date date) : _date(date) {}
|
||||
|
||||
bool CompareDate::operator()(const std::pair<Date, float> &pair) const {
|
||||
return pair.first >= _date;
|
||||
}
|
||||
|
Reference in New Issue
Block a user