diff --git a/cpp00/ex02/.clangd b/cpp00/ex02/.clangd index 12bfffa..97fba6f 100644 --- a/cpp00/ex02/.clangd +++ b/cpp00/ex02/.clangd @@ -1,8 +1,13 @@ CompileFlags: - Compiler: clang + Compiler: clang++ Add: - "-xc++" + - "-std=c++98" + - "-Werror" + - "-Wextra" + - "-Wall" + - "-stdlib=libc++" - "-I/usr/local/include" - "-I/nix/store/pzmpyb9hxfv60vh0l67avr94h71nip1b-llvm-16.0.6-dev/include" - "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" - - "-I/Users/raphael/Documents/piscine/cpp/cpp00/ex01/includes/" + - "-I/Users/raphael/Documents/42_cursus/circle4/cpp/cpp00/ex02" diff --git a/cpp00/ex02/Account.cpp b/cpp00/ex02/Account.cpp index 23d177b..2af9916 100644 --- a/cpp00/ex02/Account.cpp +++ b/cpp00/ex02/Account.cpp @@ -6,29 +6,61 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/23 16:11:46 by rparodi #+# #+# */ -/* Updated: 2024/10/23 16:52:20 by rparodi ### ########.fr */ +/* Updated: 2024/10/25 14:11:27 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "Account.hpp" +#include +#include -Account::Account() +static void _displayTimestamp( void ) { - _nbAccounts = 0; - _totalAmount = 0; + time_t raw_time = time(0); + tm *time = localtime(&raw_time); + std::cout << "[" << time->tm_year + 1900 << "0" << time->tm_mon + 1 << time->tm_mday << "_"; + std::cout << time->tm_hour << time->tm_min << time->tm_sec << "] "; +} + +/// [19920104_091532] index:0;amount:42;created +Account::Account(int initial_deposit) +{ + _nbAccounts += 1; + _totalAmount = initial_deposit; _totalNbDeposits = 0; _totalNbWithdrawals = 0; + _displayTimestamp(); + std::cout << "index:" << _accountIndex << ";"; + std::cout << "amount:" << _totalAmount << ";"; + std::cout << "created" << std::endl; } -static int Account::getNbAccounts() +Account::~Account() { - t.size(); + _accountIndex--; + _displayTimestamp(); + std::cout << "index:" << _accountIndex << ";"; + std::cout << "amount:" << _totalAmount << ";"; + std::cout << "closed" << std::endl; } -static int Account::getTotalAmount(); + +int Account::getNbAccounts() +{ + return (1); +} + +int Account::getTotalAmount(); static int Account::getNbDeposits(); static int Account::getNbWithdrawals(); -static void Account::displayAccountsInfos(); +/// [19920104_091532] index:2;p_amount:957;deposit:564;amount:1521;nb_deposits:1 +static void Account::displayAccountsInfos() +{ + _displayTimestamp(); + std::cout << "index:" << _accountIndex << ";"; + std::cout << "amount:" << _totalAmount << ";"; + std::cout << "deposit:" << _totalNbDeposits << ";"; +} diff --git a/cpp00/ex02/Makefile b/cpp00/ex02/Makefile index 499e37c..2de8b56 100644 --- a/cpp00/ex02/Makefile +++ b/cpp00/ex02/Makefile @@ -1,12 +1,12 @@ # **************************************************************************** # -# # + # ::: :::::::: # # Makefile :+: :+: :+: # # +:+ +:+ +:+ # # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/10/23 16:47:57 by rparodi ### ########.fr # +# Updated: 2024/10/25 13:20:21 by rparodi ### ########.fr # # # # **************************************************************************** #