diff --git a/cpp00/ex00/Makefile b/cpp00/ex00/Makefile index 72b2288..1792495 100644 --- a/cpp00/ex00/Makefile +++ b/cpp00/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/04/15 01:47:51 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -15,7 +15,7 @@ SRCS = megaphone.cpp OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp00/ex01/Contact.cpp b/cpp00/ex01/Contact.cpp index f7f7113..4963660 100644 --- a/cpp00/ex01/Contact.cpp +++ b/cpp00/ex01/Contact.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 10:37:12 by apommier #+# #+# */ -/* Updated: 2022/04/21 18:32:43 by apommier ### ########.fr */ +/* Updated: 2022/07/21 09:55:59 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ std::string Contact::GetInfo(int index) { std::string str; - str = this->GetRealInfo(index); + str = this->getOneInfo(index); if (str.size() > 10) { str.resize(10); @@ -41,7 +41,7 @@ std::string Contact::GetInfo(int index) return (str); } -std::string Contact::GetRealInfo(int index) +std::string Contact::getOneInfo(int index) { if (index == 0) return (this->_first_name); diff --git a/cpp00/ex01/Contact.hpp b/cpp00/ex01/Contact.hpp index 419df3e..08abfc8 100644 --- a/cpp00/ex01/Contact.hpp +++ b/cpp00/ex01/Contact.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 10:37:15 by apommier #+# #+# */ -/* Updated: 2022/04/21 18:00:26 by apommier ### ########.fr */ +/* Updated: 2022/07/21 09:55:59 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ class Contact { ~Contact(void); void FillContact(std::string *info); std::string GetInfo(int index); - std::string GetRealInfo(int index); + std::string getOneInfo(int index); private: diff --git a/cpp00/ex01/Makefile b/cpp00/ex01/Makefile index ca0aefa..7b3efeb 100644 --- a/cpp00/ex01/Makefile +++ b/cpp00/ex01/Makefile @@ -6,18 +6,18 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/04/15 01:47:51 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:49:19 by apommier ### ########.fr # # # # **************************************************************************** # -NAME = a.out +NAME = phoneBook SRCS = main.cpp\ Contact.cpp\ PhoneBook.cpp OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror -g +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp00/ex01/PhoneBook.cpp b/cpp00/ex01/PhoneBook.cpp index b714057..1ebc6b1 100644 --- a/cpp00/ex01/PhoneBook.cpp +++ b/cpp00/ex01/PhoneBook.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 10:37:20 by apommier #+# #+# */ -/* Updated: 2022/04/21 18:32:32 by apommier ### ########.fr */ +/* Updated: 2022/07/21 20:05:15 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,21 +14,20 @@ PhoneBook::PhoneBook(void) { - int index = 0; - + this->_NbrContact = -1; + while (this->_NbrContact < 8) + this->_Contact[this->_NbrContact++] = 0; this->_NbrContact = 0; - while (index < 8) - _Contact[index++] = 0; - return ; } PhoneBook::~PhoneBook(void) -{ - return ; +{ } void PhoneBook::StoreContact(Contact *NewContact) { + if (_Contact[this->_NbrContact]) + delete _Contact[this->_NbrContact] ; _Contact[this->_NbrContact] = NewContact; if (this->_NbrContact == 8) this->_NbrContact = 0; @@ -43,11 +42,11 @@ void PhoneBook::PrintContact(int index) std::cout << "There is no contact at this index" << std::endl; return ; } - std::cout << std::setw(10) << "First name: " << this->_Contact[index]->GetRealInfo(0) << std::endl; - std::cout << std::setw(10) << "Last name: " << this->_Contact[index]->GetRealInfo(1) << std::endl; - std::cout << std::setw(10) << "Nickname: " << this->_Contact[index]->GetRealInfo(2) << std::endl; - std::cout << std::setw(10) << "Phone number: " << this->_Contact[index]->GetRealInfo(3) << std::endl; - std::cout << std::setw(10) << "Darkest secret: " << this->_Contact[index]->GetRealInfo(4) << std::endl; + std::cout << std::setw(10) << "First name: " << this->_Contact[index]->getOneInfo(0) << std::endl; + std::cout << std::setw(10) << "Last name: " << this->_Contact[index]->getOneInfo(1) << std::endl; + std::cout << std::setw(10) << "Nickname: " << this->_Contact[index]->getOneInfo(2) << std::endl; + std::cout << std::setw(10) << "Phone number: " << this->_Contact[index]->getOneInfo(3) << std::endl; + std::cout << std::setw(10) << "Darkest secret: " << this->_Contact[index]->getOneInfo(4) << std::endl; } void PhoneBook::PrintIndex() @@ -66,7 +65,7 @@ void PhoneBook::PrintIndex() } if (!index) std::cout << "There is no contact\n"; - else + if (index) { while (1) { @@ -76,16 +75,22 @@ void PhoneBook::PrintIndex() std::cout << "Bad entry" << std::endl; else { - index = nbr[0] - 48; + index = nbr[0] - '0'; if (!index || index > 8) std::cout << "Bad entry" << std::endl; else { + std::cout << index << "index \n"; this->PrintContact(index - 1); - break; + return ; } } } } } +void PhoneBook::deleteContact() +{ + for (int i = 0; this->_Contact[i] && i < 8; i++) + delete this->_Contact[i]; +} diff --git a/cpp00/ex01/PhoneBook.hpp b/cpp00/ex01/PhoneBook.hpp index 8b7379d..2bf7027 100644 --- a/cpp00/ex01/PhoneBook.hpp +++ b/cpp00/ex01/PhoneBook.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 10:37:24 by apommier #+# #+# */ -/* Updated: 2022/04/21 17:57:29 by apommier ### ########.fr */ +/* Updated: 2022/07/21 19:58:59 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,9 @@ class PhoneBook { void StoreContact(Contact *NewContact); void PrintContact(int index); void PrintIndex(); - private: + void deleteContact(); + + private: int _NbrContact; class Contact *_Contact[8]; diff --git a/cpp00/ex01/main.cpp b/cpp00/ex01/main.cpp index 0898e41..1edc3db 100644 --- a/cpp00/ex01/main.cpp +++ b/cpp00/ex01/main.cpp @@ -6,14 +6,15 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/17 15:55:40 by apommier #+# #+# */ -/* Updated: 2022/07/20 12:19:30 by apommier ### ########.fr */ +/* Updated: 2022/07/21 20:01:53 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ #include "Contact.hpp" #include "PhoneBook.hpp" +#include -void PrintMessage(int index) +void PrintMessage(int index) { if (index == 0) std::cout << "Enter your fisrt name: "; @@ -27,23 +28,21 @@ void PrintMessage(int index) std::cout << "Enter your darkest secret: "; } -void search_contact(PhoneBook *Book, Contact *Contact) -{ - -} - -void add_contact(PhoneBook *Book, Contact *Contact) +void add_contact(PhoneBook *Book ) { int index = 0; std::string line; std::string info[5]; - + Contact *Contact = new class Contact; + while (index < 5) { PrintMessage(index); std::getline(std::cin, line); info[index] = line; - if (!line.empty()) + if (index == 3 && line.find_first_not_of("0123456789") != std::string::npos) + index = 3; + else if (!line.empty() && line.find_last_not_of(" ") != std::string::npos ) index++; } Contact->FillContact(info); @@ -55,23 +54,28 @@ int main(int ac, char **av) PhoneBook book; Contact contact; std::string line; - int NbrContact = 0; + (void)av; if (ac != 1) { - std::cout << "too much arguments\n"; + std::cout << "Too much arguments\n"; return (0); } std::cout << "Enter a command : ADD | SEARCH | EXIT" << std::endl; while (line != "EXIT") { std::getline(std::cin, line); + if (line != "SEARCH") + std::cout << "Enter a command : ADD | SEARCH | EXIT1" << std::endl; if (line == "ADD") - add_contact(&book, &contact); + add_contact(&book); else if (line == "SEARCH") book.PrintIndex(); - else + else if (line != "EXIT" && !line.empty()) std::cout << "Invalid command" << std::endl; + if (line != "SEARCH" && line.size()) + std::cout << "Enter a command : ADD | SEARCH | EXIT2" << std::endl; } + book.deleteContact(); return (0); } \ No newline at end of file diff --git a/cpp00/ex02/Account.cpp b/cpp00/ex02/Account.cpp index 3c58104..ebd059c 100644 --- a/cpp00/ex02/Account.cpp +++ b/cpp00/ex02/Account.cpp @@ -11,91 +11,121 @@ /* ************************************************************************** */ #include "Account.hpp" +#include +#include +#include + +int Account::_nbAccounts = 0; +int Account::_totalAmount = 0; +int Account::_totalNbDeposits = 0; +int Account::_totalNbWithdrawals = 0; int Account::getNbAccounts( void ) { - return (this->_nbAccounts); + return (Account::_nbAccounts); } int Account::getTotalAmount( void ) { - return (this->_totalAmount); + return (Account::_totalAmount); } int Account::getNbDeposits( void ) { - return (this->_nbDeposits); + return (Account::_totalNbDeposits); } int Account::getNbWithdrawals( void ) { - return (this->_nbWithdrawals); + return (Account::_totalNbWithdrawals); } void Account::displayAccountsInfos( void ) { - + Account::_displayTimestamp(); + std::cout << " accounts:" << getNbAccounts(); + std::cout << ";total:" << getTotalAmount(); + std::cout << ";deposits:" << getNbDeposits(); + std::cout << ";withdrawals:" << getNbWithdrawals() << std::endl; } Account::Account( int initial_deposit ) { - this->_nbAccounts = 0; - this->_totalAmount = initial_deposit; - this->_totalNbDeposits = 0; - this->_totalNbWithdrawals = 0; - this->_accountIndex = 0; + this->_accountIndex = Account::_nbAccounts++; + this->_totalAmount += initial_deposit; this->_amount = initial_deposit; this->_nbDeposits = 0; this->_nbWithdrawals = 0; -} - -Account::Account() -{ - this->_nbAccounts = 0; - this->_totalAmount = 0; - this->_totalNbDeposits = 0; - this->_totalNbWithdrawals = 0; - this->_accountIndex = 0; - this->_amount = 0; - this->_nbDeposits = 0; - this->_nbWithdrawals = 0; + Account::_displayTimestamp(); + std::cout << " index:" << this->_accountIndex << ";amount:" << checkAmount() << ";created" << std::endl; } Account::~Account( void ) { - + Account::_displayTimestamp(); + std::cout << " index:" << this->_accountIndex << ";amount:" << checkAmount() << ";closed" << std::endl; } void Account::makeDeposit( int deposit ) { - this->_amount += deposit; + this->_nbDeposits = 1; this->_totalNbDeposits++; + Account::_displayTimestamp(); + std::cout << " index:" << this->_accountIndex; + std::cout << ";p_amount:" << this->checkAmount(); + this->_amount += deposit; + this->_totalAmount += deposit; + std::cout << ";deposit:" << deposit; + std::cout << ";amount:" << this->checkAmount(); + std::cout << ";nb_deposits:"<< this->_nbDeposits<< std::endl; } bool Account::makeWithdrawal( int withdrawal ) { - if (this->_totalAmount >= withdrawal) + Account::_displayTimestamp(); + std::cout << " index:" << this->_accountIndex; + std::cout << ";p_amount:" << this->checkAmount(); + std::cout << ";withdrawal:"; + if (this->_amount >= withdrawal) { this->_nbWithdrawals = 1; this->_totalNbWithdrawals++; this->_amount -= withdrawal; + this->_totalAmount -= withdrawal; + std::cout << withdrawal; + std::cout << ";amount:" << this->checkAmount(); + std::cout << ";nb_withdrawals:"<< this->_nbWithdrawals << std::endl; return (1); - } + } + std::cout << "refused\n"; return (0); } int Account::checkAmount( void ) const { - + return (this->_amount); } void Account::displayStatus( void ) const { - + Account::_displayTimestamp(); + std::cout << " index:" << this->_accountIndex; + std::cout << ";amount:" << checkAmount(); + std::cout << ";deposits:" << this->_nbDeposits; + std::cout << ";withdrawals:" << this->_nbWithdrawals << std::endl; } void Account::_displayTimestamp( void ) { - -} + time_t rawtime; + struct tm *timeinfo; + char buffer[18]; + + time (&rawtime); + timeinfo = localtime(&rawtime); + strftime (buffer, 20, "[%G%m%d_%H%M%S]", timeinfo); + //const char *buffeer = "[19920104_091532]"; + //std::cout << buffeer; + std::cout << buffer; +} \ No newline at end of file diff --git a/cpp00/ex02/Makefile b/cpp00/ex02/Makefile index faea912..a8ada31 100644 --- a/cpp00/ex02/Makefile +++ b/cpp00/ex02/Makefile @@ -6,17 +6,17 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/04/15 01:47:51 by apommier #+# #+# # -# Updated: 2022/07/20 12:51:45 by apommier ### ########.fr # +# Updated: 2022/07/22 07:49:56 by apommier ### ########.fr # # # # **************************************************************************** # -NAME = a.out +NAME = account SRCS = Account.cpp\ tests.cpp OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex00/Makefile b/cpp01/ex00/Makefile index e6c3e08..ca37a7b 100644 --- a/cpp01/ex00/Makefile +++ b/cpp01/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/08 16:30:13 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -18,7 +18,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex01/Makefile b/cpp01/ex01/Makefile index c11fc69..807059d 100644 --- a/cpp01/ex01/Makefile +++ b/cpp01/ex01/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/08 16:30:13 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex02/Makefile b/cpp01/ex02/Makefile index 34dabfa..9be32d5 100644 --- a/cpp01/ex02/Makefile +++ b/cpp01/ex02/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/10 14:10:33 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -14,7 +14,7 @@ NAME = a.out SRCS = main.cpp OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex03/Makefile b/cpp01/ex03/Makefile index d1c5938..f24c940 100644 --- a/cpp01/ex03/Makefile +++ b/cpp01/ex03/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/16 21:39:06 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ Weapon.cpp OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex04/Makefile b/cpp01/ex04/Makefile index a2f0004..b1d8ee4 100644 --- a/cpp01/ex04/Makefile +++ b/cpp01/ex04/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/19 16:15:23 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -15,7 +15,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex05/Harl.cpp b/cpp01/ex05/Harl.cpp index 70ec64e..1f6dd65 100644 --- a/cpp01/ex05/Harl.cpp +++ b/cpp01/ex05/Harl.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/21 22:07:00 by apommier #+# #+# */ -/* Updated: 2022/07/19 10:42:46 by apommier ### ########.fr */ +/* Updated: 2022/07/22 09:39:35 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp01/ex05/Makefile b/cpp01/ex05/Makefile index 8232634..dac2921 100644 --- a/cpp01/ex05/Makefile +++ b/cpp01/ex05/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/21 22:05:40 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex05/main.cpp b/cpp01/ex05/main.cpp index 4b83a51..2fd96d0 100644 --- a/cpp01/ex05/main.cpp +++ b/cpp01/ex05/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/21 22:06:54 by apommier #+# #+# */ -/* Updated: 2022/06/21 23:43:26 by apommier ### ########.fr */ +/* Updated: 2022/07/22 09:26:27 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp01/ex06/Harl.cpp b/cpp01/ex06/Harl.cpp index e941a83..4341af2 100644 --- a/cpp01/ex06/Harl.cpp +++ b/cpp01/ex06/Harl.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/21 23:39:20 by apommier #+# #+# */ -/* Updated: 2022/06/21 23:44:25 by apommier ### ########.fr */ +/* Updated: 2022/07/22 09:40:02 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,6 +34,19 @@ void Harl::complain(std::string level) } } +int Harl::ChooseComplain(std::string level) +{ + void (Harl::*complaint[])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error}; + std::string levelTab[4] = {"DEBUG", "INFO", "WARNING", "ERROR"}; + for (int i = 0; i < 4 ; i++) + { + void (Harl::*selectedComplaint)( void ) = complaint[i]; + if (level == levelTab[i]) + return (i); + } +} + + void Harl::debug() { std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-specialketchup burger. I really do!\n"; diff --git a/cpp01/ex06/Harl.hpp b/cpp01/ex06/Harl.hpp index 0fa41e5..2456ae2 100644 --- a/cpp01/ex06/Harl.hpp +++ b/cpp01/ex06/Harl.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/21 23:39:11 by apommier #+# #+# */ -/* Updated: 2022/06/21 23:44:12 by apommier ### ########.fr */ +/* Updated: 2022/07/22 09:41:32 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,7 @@ class Harl { Harl(); ~Harl(); + int chooseComplain(std::string level); void complain(std::string level); private: diff --git a/cpp01/ex06/Makefile b/cpp01/ex06/Makefile index 20a5614..b38f446 100644 --- a/cpp01/ex06/Makefile +++ b/cpp01/ex06/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/21 23:38:45 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp01/ex06/main.cpp b/cpp01/ex06/main.cpp index e124d8a..f56d030 100644 --- a/cpp01/ex06/main.cpp +++ b/cpp01/ex06/main.cpp @@ -6,31 +6,48 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/21 23:40:41 by apommier #+# #+# */ -/* Updated: 2022/06/21 23:52:51 by apommier ### ########.fr */ +/* Updated: 2022/07/22 09:44:33 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ #include "Harl.hpp" +void harFilter(Harl harl, std::string level) +{ + int goodLevel = harl.chooseComplain(level) + 1; + std::string levelTab[4] = {"DEBUG", "INFO", "WARNING", "ERROR"}; + + switch (goodLevel) + { + case 1 : + harl.complain("DEBUG"); + harl.complain("INFO"); + harl.complain("WARNING"); + harl.complain("ERROR"); + case 2 : + harl.complain("INFO"); + harl.complain("WARNING"); + harl.complain("ERROR"); + case 3 : + harl.complain("WARNING"); + harl.complain("ERROR"); + case 4 : + harl.complain("ERROR"); + default : + std::cout << "[ Probably complaining about insignificant problems ]\n"; + } +} + int main(int ac, char **av) { Harl harl; - bool freeHarl = 0; - std::string levelTab[4] = {"DEBUG", "INFO", "WARNING", "ERROR"}; + std::cout << ac << std::endl; if (ac != 2) - return (0); - for (int j = 0; j < 4; j++) { - if (av[1] == levelTab[j]) - freeHarl = 1; - if (freeHarl == 1) - { - while (j < 4) - { - harl.complain(levelTab[j]); - j++; - } - } + std::cerr << "Bad entry\n"; + return (1); } + harFilter(harl, av[1]); + return (0); } \ No newline at end of file diff --git a/cpp02/ex00/Makefile b/cpp02/ex00/Makefile index 8f7c7eb..5c8b146 100644 --- a/cpp02/ex00/Makefile +++ b/cpp02/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/22 00:57:33 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp02/ex01/Makefile b/cpp02/ex01/Makefile index fc8ee60..cfbe40a 100644 --- a/cpp02/ex01/Makefile +++ b/cpp02/ex01/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/22 15:30:34 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp02/ex02/Makefile b/cpp02/ex02/Makefile index dc327d9..cfbe40a 100644 --- a/cpp02/ex02/Makefile +++ b/cpp02/ex02/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/06/22 15:30:34 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:44 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp03/ex00/Makefile b/cpp03/ex00/Makefile index e57ce3e..afe1c26 100644 --- a/cpp03/ex00/Makefile +++ b/cpp03/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/13 05:22:57 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp03/ex01/Makefile b/cpp03/ex01/Makefile index 403fc25..bdecbd9 100644 --- a/cpp03/ex01/Makefile +++ b/cpp03/ex01/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/13 05:22:57 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp03/ex02/Makefile b/cpp03/ex02/Makefile index a81e65e..b93f504 100644 --- a/cpp03/ex02/Makefile +++ b/cpp03/ex02/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/13 05:22:57 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -18,7 +18,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp04/ex00/Makefile b/cpp04/ex00/Makefile index c62d3a8..e787502 100644 --- a/cpp04/ex00/Makefile +++ b/cpp04/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/14 02:04:13 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -20,7 +20,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp04/ex01/Makefile b/cpp04/ex01/Makefile index c9a8ac1..0205728 100644 --- a/cpp04/ex01/Makefile +++ b/cpp04/ex01/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/14 02:04:13 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -21,7 +21,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp04/ex02/Makefile b/cpp04/ex02/Makefile index c9a8ac1..0205728 100644 --- a/cpp04/ex02/Makefile +++ b/cpp04/ex02/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/14 02:04:13 by apommier #+# #+# # -# Updated: 2022/07/18 20:52:38 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -21,7 +21,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp05/ex00/Makefile b/cpp05/ex00/Makefile index 960a5d3..965ea00 100644 --- a/cpp05/ex00/Makefile +++ b/cpp05/ex00/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/18 21:34:54 by apommier #+# #+# # -# Updated: 2022/07/19 10:52:12 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp05/ex01/Makefile b/cpp05/ex01/Makefile index 709b26e..6a35d3d 100644 --- a/cpp05/ex01/Makefile +++ b/cpp05/ex01/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/18 21:34:54 by apommier #+# #+# # -# Updated: 2022/07/19 12:02:15 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: diff --git a/cpp05/ex02/Makefile b/cpp05/ex02/Makefile index 709b26e..6a35d3d 100644 --- a/cpp05/ex02/Makefile +++ b/cpp05/ex02/Makefile @@ -6,7 +6,7 @@ # By: apommier +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/07/18 21:34:54 by apommier #+# #+# # -# Updated: 2022/07/19 12:02:15 by apommier ### ########.fr # +# Updated: 2022/07/22 07:48:18 by apommier ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS = main.cpp\ OBJS = ${SRCS:.cpp=.o} CC = c++ -CFLAGS = -Wall -Wextra -Werror +CFLAGS = -Wall -Wextra -Werror -std=c++98 RM = rm -rf .cpp.o: