From 52ccde26938e29a33ea977a56377d18acf81e626 Mon Sep 17 00:00:00 2001 From: narnaud Date: Fri, 17 Jun 2022 13:32:47 +0200 Subject: [PATCH] 01 --- CPP01/ex00/Makefile | 20 +++++++++++ CPP01/ex00/Zombie.cpp | 28 ++++++++++++++++ CPP01/ex00/Zombie.hpp | 37 +++++++++++++++++++++ CPP01/ex00/main.cpp | 24 ++++++++++++++ CPP01/ex00/newZombie.cpp | 19 +++++++++++ CPP01/ex00/randomChump.cpp | 19 +++++++++++ CPP01/ex01/Makefile | 19 +++++++++++ CPP01/ex01/Zombie.cpp | 35 ++++++++++++++++++++ CPP01/ex01/Zombie.hpp | 39 ++++++++++++++++++++++ CPP01/ex01/apocalypse | Bin 0 -> 41892 bytes CPP01/ex01/main.cpp | 26 +++++++++++++++ CPP01/ex01/zombieHorde.cpp | 25 ++++++++++++++ CPP01/ex02/main.cpp | 31 +++++++++++++++++ CPP01/ex03/HumanA.cpp | 20 +++++++++++ CPP01/ex03/HumanA.hpp | 28 ++++++++++++++++ CPP01/ex03/HumanB.cpp | 33 +++++++++++++++++++ CPP01/ex03/HumanB.hpp | 30 +++++++++++++++++ CPP01/ex03/Makefile | 21 ++++++++++++ CPP01/ex03/Weapon.cpp | 26 +++++++++++++++ CPP01/ex03/Weapon.hpp | 33 +++++++++++++++++++ CPP01/ex03/main.cpp | 34 +++++++++++++++++++ CPP01/ex04/main.cpp | 54 ++++++++++++++++++++++++++++++ CPP01/ex05/Harl.cpp | 66 +++++++++++++++++++++++++++++++++++++ CPP01/ex05/Harl.hpp | 34 +++++++++++++++++++ CPP01/ex05/main.cpp | 23 +++++++++++++ 25 files changed, 724 insertions(+) create mode 100644 CPP01/ex00/Makefile create mode 100644 CPP01/ex00/Zombie.cpp create mode 100644 CPP01/ex00/Zombie.hpp create mode 100644 CPP01/ex00/main.cpp create mode 100644 CPP01/ex00/newZombie.cpp create mode 100644 CPP01/ex00/randomChump.cpp create mode 100644 CPP01/ex01/Makefile create mode 100644 CPP01/ex01/Zombie.cpp create mode 100644 CPP01/ex01/Zombie.hpp create mode 100755 CPP01/ex01/apocalypse create mode 100644 CPP01/ex01/main.cpp create mode 100644 CPP01/ex01/zombieHorde.cpp create mode 100644 CPP01/ex02/main.cpp create mode 100644 CPP01/ex03/HumanA.cpp create mode 100644 CPP01/ex03/HumanA.hpp create mode 100644 CPP01/ex03/HumanB.cpp create mode 100644 CPP01/ex03/HumanB.hpp create mode 100644 CPP01/ex03/Makefile create mode 100644 CPP01/ex03/Weapon.cpp create mode 100644 CPP01/ex03/Weapon.hpp create mode 100644 CPP01/ex03/main.cpp create mode 100644 CPP01/ex04/main.cpp create mode 100644 CPP01/ex05/Harl.cpp create mode 100644 CPP01/ex05/Harl.hpp create mode 100644 CPP01/ex05/main.cpp diff --git a/CPP01/ex00/Makefile b/CPP01/ex00/Makefile new file mode 100644 index 0000000..4d5b7ad --- /dev/null +++ b/CPP01/ex00/Makefile @@ -0,0 +1,20 @@ +NAME = apocalypse +SRCS = main.cpp Zombie.cpp newZombie.cpp randomChump.cpp +OBJS = $(SRCS:.cpp=.o) + +CXXFLAGS = -std=c++98 -Werror -Wextra -Wall + +$(NAME): $(OBJS) + c++ $(OBJS) -o $(NAME) + +all: $(NAME) + +clean: + rm -rf $(OBJS) + +fclean: clean + rm -rf $(NAME) + +re: fclean all + +.PHONY: all clean re diff --git a/CPP01/ex00/Zombie.cpp b/CPP01/ex00/Zombie.cpp new file mode 100644 index 0000000..fbe34f7 --- /dev/null +++ b/CPP01/ex00/Zombie.cpp @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:53:11 by narnaud #+# #+# */ +/* Updated: 2022/06/14 09:45:30 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie::Zombie(string name):_name(name) +{ + cout << "*" << name << " died.*\n"; +} + +Zombie::~Zombie(void) +{ + cout << "*" << this->_name << " really died.*\n"; +} + +void Zombie::announce(void) const +{ + cout << this->_name << ": BraiiiiiiinnnzzzZ...\n"; +} diff --git a/CPP01/ex00/Zombie.hpp b/CPP01/ex00/Zombie.hpp new file mode 100644 index 0000000..c57e189 --- /dev/null +++ b/CPP01/ex00/Zombie.hpp @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:02:30 by narnaud #+# #+# */ +/* Updated: 2022/06/14 09:49:11 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef ZOMBIE_HPP +# define ZOMBIE_HPP + +# ifndef DEBUG +# define DEBUG 0 +# endif + +#include +using std::cin; +using std::cout; +using std::string; + +class Zombie +{ + public: + Zombie(string name); + ~Zombie(); + void announce(void) const; + private: + string _name; +}; + +Zombie *newZombie(string name); +void randomChump(string name); + +#endif diff --git a/CPP01/ex00/main.cpp b/CPP01/ex00/main.cpp new file mode 100644 index 0000000..14ddbb6 --- /dev/null +++ b/CPP01/ex00/main.cpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 07:59:29 by narnaud #+# #+# */ +/* Updated: 2022/06/14 09:46:09 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +# include "Zombie.hpp" + +int main(void) +{ + Zombie *marc = newZombie("Marc"); + marc->announce(); + delete marc; + randomChump("Aurel"); + if (DEBUG) + system("leaks apocalypse"); + return (EXIT_SUCCESS); +} diff --git a/CPP01/ex00/newZombie.cpp b/CPP01/ex00/newZombie.cpp new file mode 100644 index 0000000..3690cd9 --- /dev/null +++ b/CPP01/ex00/newZombie.cpp @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* newZombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:17:02 by narnaud #+# #+# */ +/* Updated: 2022/06/14 09:43:58 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie *newZombie(string name) +{ + Zombie *ret = new Zombie(name); + return (ret); +} diff --git a/CPP01/ex00/randomChump.cpp b/CPP01/ex00/randomChump.cpp new file mode 100644 index 0000000..81f0033 --- /dev/null +++ b/CPP01/ex00/randomChump.cpp @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* randomChump.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:18:57 by narnaud #+# #+# */ +/* Updated: 2022/06/14 09:43:58 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +void randomChump(string name) +{ + Zombie zomb = Zombie(name); + zomb.announce(); +} diff --git a/CPP01/ex01/Makefile b/CPP01/ex01/Makefile new file mode 100644 index 0000000..27da46f --- /dev/null +++ b/CPP01/ex01/Makefile @@ -0,0 +1,19 @@ +NAME = apocalypse +SRCS = main.cpp Zombie.cpp zombieHorde.cpp +OBJS = $(SRCS:.cpp=.o) +CXXFLAGS = -g -std=c++98 -Werror -Wextra -Wall + +$(NAME): $(OBJS) + c++ $(OBJS) -o $(NAME) + +all: $(NAME) + +clean: + rm -rf $(OBJS) + +fclean: clean + rm -rf $(NAME) + +re: clean all + +.PHONY: all clean fclean re diff --git a/CPP01/ex01/Zombie.cpp b/CPP01/ex01/Zombie.cpp new file mode 100644 index 0000000..7cc1cf8 --- /dev/null +++ b/CPP01/ex01/Zombie.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:53:11 by narnaud #+# #+# */ +/* Updated: 2022/06/16 12:43:16 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie::Zombie(){} + +Zombie::Zombie(string name):_name(name) +{ + cout << "*" << _name << " died.*\n"; +} + +Zombie::~Zombie(void) +{ + cout << "*" << _name << " really died.*\n"; +} + +void Zombie::announce(void) const +{ + cout << _name << ": BraiiiiiiinnnzzzZ...\n"; +} + +void Zombie::setName(string name) +{ + _name = name; +} diff --git a/CPP01/ex01/Zombie.hpp b/CPP01/ex01/Zombie.hpp new file mode 100644 index 0000000..d115ed5 --- /dev/null +++ b/CPP01/ex01/Zombie.hpp @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:02:30 by narnaud #+# #+# */ +/* Updated: 2022/06/16 12:27:01 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef ZOMBIE_HPP +# define ZOMBIE_HPP + +# ifndef DEBUG +# define DEBUG 0 +# endif +# define ZB_AMOUNT 8 + +#include +using std::cin; +using std::cout; +using std::string; + +class Zombie +{ + public: + Zombie(void); + Zombie(string name); + ~Zombie(); + void announce(void) const; + void setName(string name); + private: + string _name; +}; + +Zombie *zombieHorde(int amount, string name); + +#endif diff --git a/CPP01/ex01/apocalypse b/CPP01/ex01/apocalypse new file mode 100755 index 0000000000000000000000000000000000000000..cc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 zL_1;>3p|pu)V$!Ub$lGIqmK!+FGW)TCqGdr8eE={AyLosh7>_(sqA=W93EmC<{2T8 zN$%i$(BDFxt*p6neCn*%->|*4?Y?ANJ=>3BtD_A;6G8zi+EUG}yHc3RZcnwDzi)z$ z-dS$`!iujLr|K|@Mdu$V+FLf(x36A}&*BYk-(9Ju)^s!e48xMu@i@qv*T4l2&D+e+0w#;MVAJn266Wq>uOB@T|OoJ;Omjk?WnUhC!Y4Omuxa z*A0J(hGlZq^;gi6(Q(i2IPX`#+Uk|>EWRe!8DMa!lVij{-|I{-=i+btO)uwq4Xij$ zerbWr4%5rI7^O@v=jLAw;P1Vae=ATrF`Zt{H7~o0#_NtFy((Wd7xhIGSZeqM?e)&|rY4E>L)IJhi*8H%rEE$jaSXN*XC literal 0 HcmV?d00001 diff --git a/CPP01/ex01/main.cpp b/CPP01/ex01/main.cpp new file mode 100644 index 0000000..43bcb50 --- /dev/null +++ b/CPP01/ex01/main.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 07:59:29 by narnaud #+# #+# */ +/* Updated: 2022/06/16 12:44:26 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +# include "Zombie.hpp" + +int main(void) +{ + Zombie *zombs = zombieHorde(ZB_AMOUNT, "Zombie"); + int i = 0; + + while (i < ZB_AMOUNT) + zombs[i++].announce(); + delete [] zombs; + if (DEBUG) + system("leaks apocalypse"); + return (EXIT_SUCCESS); +} diff --git a/CPP01/ex01/zombieHorde.cpp b/CPP01/ex01/zombieHorde.cpp new file mode 100644 index 0000000..18c7511 --- /dev/null +++ b/CPP01/ex01/zombieHorde.cpp @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* zombieHorde.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 08:17:02 by narnaud #+# #+# */ +/* Updated: 2022/06/16 12:47:20 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie *zombieHorde(int N, string name) +{ + Zombie *ret = new Zombie[N]; + int n = 0; + while (n < N) + { + ret[n].setName(name + std::to_string(n)); + n++; + } + return (ret); +} diff --git a/CPP01/ex02/main.cpp b/CPP01/ex02/main.cpp new file mode 100644 index 0000000..9626a81 --- /dev/null +++ b/CPP01/ex02/main.cpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 11:01:07 by narnaud #+# #+# */ +/* Updated: 2022/06/14 11:08:21 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +using std::string; +using std::cout; +using std::endl; + +int main(void) +{ + string str = "HI THIS IS BRAIN"; + string *stringPTR = &str; + string &stringREF = str; + + cout << &str << endl; + cout << stringPTR << endl; + cout << &stringREF << endl; + + cout << str << endl; + cout << *stringPTR << endl; + cout << stringREF << endl; +} diff --git a/CPP01/ex03/HumanA.cpp b/CPP01/ex03/HumanA.cpp new file mode 100644 index 0000000..1252c19 --- /dev/null +++ b/CPP01/ex03/HumanA.cpp @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 13:34:06 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:10:29 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "HumanA.hpp" + +HumanA::HumanA(string name, Weapon & weap ):_name(name),_weapon(weap){} + +void HumanA::attack(void) const +{ + std::cout << _name << " attacks with their " << _weapon.getType() << endl; +} diff --git a/CPP01/ex03/HumanA.hpp b/CPP01/ex03/HumanA.hpp new file mode 100644 index 0000000..ce7ad11 --- /dev/null +++ b/CPP01/ex03/HumanA.hpp @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 12:52:11 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:33:40 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef HUMANA_HPP +# define HUMANA_HPP + +# include "Weapon.hpp" + +class HumanA +{ + public: + HumanA(string name, Weapon &weap); + void attack(void) const; + private: + string _name; + Weapon &_weapon; +}; + +#endif diff --git a/CPP01/ex03/HumanB.cpp b/CPP01/ex03/HumanB.cpp new file mode 100644 index 0000000..6555eba --- /dev/null +++ b/CPP01/ex03/HumanB.cpp @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/16 09:13:28 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:12:56 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "HumanB.hpp" + + +HumanB::HumanB(string name):_name(name), _weapon(NULL){} + +HumanB::HumanB(string name, Weapon &weap):_name(name), _weapon(&weap){} + + +void HumanB::attack(void) const +{ + std::cout << _name << " attacks with their "; + if (_weapon) + cout << _weapon->getType() << endl; + else + cout << "fists\n"; +} + +void HumanB::setWeapon(Weapon &weap) +{ + _weapon = &weap; +} diff --git a/CPP01/ex03/HumanB.hpp b/CPP01/ex03/HumanB.hpp new file mode 100644 index 0000000..b4bef57 --- /dev/null +++ b/CPP01/ex03/HumanB.hpp @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 12:54:11 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:33:28 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef HUMANB_HPP +# define HUMANB_HPP + +# include "Weapon.hpp" + +class HumanB +{ + public: + HumanB(string name); + HumanB(string name, Weapon &weap); + void attack(void) const; + void setWeapon(Weapon &weap); + private: + string _name; + Weapon *_weapon; +}; + +#endif diff --git a/CPP01/ex03/Makefile b/CPP01/ex03/Makefile new file mode 100644 index 0000000..a5e16c6 --- /dev/null +++ b/CPP01/ex03/Makefile @@ -0,0 +1,21 @@ +NAME = warfare + +SRCS = main.cpp Weapon.cpp HumanA.cpp HumanB.cpp +OBJS = $(SRCS:.cpp=.o) + +CXXFLAGS = -std=c++98 -Werror -Wextra -Wall + +$(NAME): $(OBJS) + c++ $(OBJS) -o $(NAME) + +all: $(NAME) + +clean: + rm -rf $(OBJS) + +fclean: clean + rm -rf $(NAME) + +re: fclean all + +.PHONY: all clean fclean re diff --git a/CPP01/ex03/Weapon.cpp b/CPP01/ex03/Weapon.cpp new file mode 100644 index 0000000..e52f882 --- /dev/null +++ b/CPP01/ex03/Weapon.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 12:51:23 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:08:02 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Weapon.hpp" + +Weapon::Weapon(string type):_type(type){} + +const string &Weapon::getType(void) const +{ + return (this->_type); +} + +void Weapon::setType(string type) +{ + this->_type = type; +} + diff --git a/CPP01/ex03/Weapon.hpp b/CPP01/ex03/Weapon.hpp new file mode 100644 index 0000000..52a2064 --- /dev/null +++ b/CPP01/ex03/Weapon.hpp @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 12:50:31 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:04:50 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef WEAPON_HPP +# define WEAPON_HPP + +# include + +using std::string; +using std::cout; +using std::cin; +using std::endl; + +class Weapon +{ + public: + Weapon(void); + Weapon(string type); + const string &getType(void) const; + void setType(string type); + private: + string _type; +}; + +#endif diff --git a/CPP01/ex03/main.cpp b/CPP01/ex03/main.cpp new file mode 100644 index 0000000..78a293e --- /dev/null +++ b/CPP01/ex03/main.cpp @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/14 12:55:24 by narnaud #+# #+# */ +/* Updated: 2022/06/16 10:02:39 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "HumanA.hpp" +#include "HumanB.hpp" + +int main() +{ + { + Weapon club = Weapon("crude spiked club"); + HumanA bob("Bob", club); + bob.attack(); + club.setType("some other type of club"); + bob.attack(); + } + { + Weapon club = Weapon("crude spiked club"); + HumanB jim("Jim"); + jim.setWeapon(club); + jim.attack(); + club.setType("some other type of club"); + jim.attack(); + } + return 0; +} diff --git a/CPP01/ex04/main.cpp b/CPP01/ex04/main.cpp new file mode 100644 index 0000000..b86caf8 --- /dev/null +++ b/CPP01/ex04/main.cpp @@ -0,0 +1,54 @@ +/* + * my_sed(argc,argv) + * filename = argv[1]; + * s1 = argv[2]; + * s2 = argv[3]; + * input::ifstream ifs; + * input = open(filename, std::ifstream::in); + * + * + * + * */ + + +#include +#include +using std::string; +using std::ifstream; +using std::ofstream; + + +int main(int argc, char **argv) +{ + string text; + string buffer; + string filename; + string oldStr; + string newStr; + int oldLen; + int i = 0, fileLen = 0; + + if (argc != 4) + return (EXIT_FAILURE); + ifstream input(argv[1]); + oldStr = argv[2]; + newStr = argv[3]; + while (getline(input, buffer)) + text += buffer; + input.close(); + fileLen = text.length(); + oldLen = oldStr.length(); + while (i < fileLen) + { + i = text.find(oldStr, i); + if (i == -1) + break ; + text.erase(i, oldLen); + text.insert(i, newStr); + } + filename = argv[1]; + ofstream output(filename.append(".replace")); + output << text; + output.close(); + return (EXIT_SUCCESS); +} diff --git a/CPP01/ex05/Harl.cpp b/CPP01/ex05/Harl.cpp new file mode 100644 index 0000000..f4029f1 --- /dev/null +++ b/CPP01/ex05/Harl.cpp @@ -0,0 +1,66 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Harl.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/17 11:14:29 by narnaud #+# #+# */ +/* Updated: 2022/06/17 13:29:12 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Harl.hpp" + +Harl::Harl (void) { + std::cout << "Harl default constructor called " << std::endl; +} + +Harl::Harl (Harl const & src) { + + std::cout << "Harl copy constructor called" << std::endl; +} + +Harl & Harl::operator= (Harl const & src) { + + std::cout << "Harl assignment operator called" << std::endl; + return (*this); +} + +Harl::~Harl (void) { + + std::cout << "Harl default destructor called" << std::endl; +} + +void Harl::_debug(void) +{ + std::cout << "Debug : ..." << std::endl; +} + +void Harl::_info(void) +{ + std::cout << "Info: ..." << std::endl; +} + +void Harl::_warning(void) +{ + std::cout << "Warning: ..." << std::endl; +} + +void Harl::_error(void) +{ + std::cout << "Error: ..." << std::endl; +} + +void Harl::_complain(string level) { + + void (Harl::*fcts[])(void) = { + &Harl::_debug, &Harl::_info, &Harl::_warning, &Harl::_error}; + string ids = "DIWE"; + int i = 0; + while (ids[i] && ids[i] != level[0]) + i++; + if (ids[i]) + (Harl::*fcts[i])(); +} + diff --git a/CPP01/ex05/Harl.hpp b/CPP01/ex05/Harl.hpp new file mode 100644 index 0000000..8d3d069 --- /dev/null +++ b/CPP01/ex05/Harl.hpp @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Harl.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/17 11:13:50 by narnaud #+# #+# */ +/* Updated: 2022/06/17 13:12:45 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include +using std::string; + +class Harl { + + public: + + Harl (void); + Harl (Harl const & src); + ~Harl (void); + Harl & operator= (Harl const & src); + void _complain(string level); + + private: + void _debug(void); + void _info(void); + void _warning(void); + void _error(void); + +}; diff --git a/CPP01/ex05/main.cpp b/CPP01/ex05/main.cpp new file mode 100644 index 0000000..b238611 --- /dev/null +++ b/CPP01/ex05/main.cpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/17 11:37:33 by narnaud #+# #+# */ +/* Updated: 2022/06/17 12:45:24 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Harl.hpp" + +int main(void) +{ + Harl bot; + bot._complain("DEBUG"); + bot._complain("INFO"); + bot._complain("WARNING"); + bot._complain("ERROR"); + +}