diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..67a4415 --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 15:31:53 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = Zombie +SRC = main.cpp Zombie.cpp newZombie.cpp randomChump.cpp + +-include ../common.mk + diff --git a/ex00/inc/Zombie.hpp b/ex00/inc/Zombie.hpp new file mode 100644 index 0000000..eab643f --- /dev/null +++ b/ex00/inc/Zombie.hpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Zombie.hpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:30:14 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +class Zombie +{ +private: + std::string name; + +public: + Zombie(); + Zombie(std::string name); + ~Zombie(); + void announce(); + void setName(std::string name); +}; + +Zombie* newZombie( std::string name ); +void randomChump( std::string name ); diff --git a/ex00/src/Zombie.cpp b/ex00/src/Zombie.cpp new file mode 100644 index 0000000..5277861 --- /dev/null +++ b/ex00/src/Zombie.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Zombie.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:21:44 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:27:56 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include "Zombie.hpp" + +Zombie::Zombie() +{ +} +Zombie::Zombie(std::string p_name) +{ + name = p_name; +} + +Zombie::~Zombie() +{ + std::cout << name << ": " << "Is destroyed!" << std::endl; +} +void Zombie::setName(std::string p_name) +{ + name = p_name; +} +void Zombie::announce() +{ + std::cout << name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl; +} diff --git a/ex00/src/main.cpp b/ex00/src/main.cpp new file mode 100644 index 0000000..e361938 --- /dev/null +++ b/ex00/src/main.cpp @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* main.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:33:25 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +int main() +{ + Zombie* zombie = newZombie("Alice"); + zombie->announce(); + randomChump("Bob"); + delete zombie; + return (0); +} \ No newline at end of file diff --git a/ex00/src/newZombie.cpp b/ex00/src/newZombie.cpp new file mode 100644 index 0000000..5ac2bd1 --- /dev/null +++ b/ex00/src/newZombie.cpp @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* newZombie.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:30:53 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:31:04 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie* newZombie(std::string name) +{ + Zombie* zombie = new Zombie(name); + return (zombie); +} \ No newline at end of file diff --git a/ex00/src/randomChump.cpp b/ex00/src/randomChump.cpp new file mode 100644 index 0000000..b012c21 --- /dev/null +++ b/ex00/src/randomChump.cpp @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* randomChump.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:30:21 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:30:49 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +void randomChump(std::string name) +{ + Zombie zombie(name); + zombie.announce(); +} \ No newline at end of file diff --git a/ex01/Makefile b/ex01/Makefile new file mode 100644 index 0000000..289485c --- /dev/null +++ b/ex01/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 16:01:32 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = Zombie +SRC = main.cpp Zombie.cpp zombieHorde.cpp + +-include ../common.mk + diff --git a/ex01/inc/Zombie.hpp b/ex01/inc/Zombie.hpp new file mode 100644 index 0000000..52c5cc2 --- /dev/null +++ b/ex01/inc/Zombie.hpp @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Zombie.hpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:59:48 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +class Zombie +{ +private: + std::string name; + +public: + Zombie(); + Zombie(std::string name); + ~Zombie(); + void announce() const; + void setName(std::string name); +}; + +Zombie* zombieHorde( int N, std::string name ); diff --git a/ex01/src/Zombie.cpp b/ex01/src/Zombie.cpp new file mode 100644 index 0000000..fa5f7e8 --- /dev/null +++ b/ex01/src/Zombie.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Zombie.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:21:44 by whaffman #+# #+# */ +/* Updated: 2025/03/21 15:59:53 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include "Zombie.hpp" + +Zombie::Zombie() +{ +} +Zombie::Zombie(std::string p_name) +{ + name = p_name; +} + +Zombie::~Zombie() +{ + std::cout << name << ": " << "Is destroyed!" << std::endl; +} +void Zombie::setName(std::string p_name) +{ + name = p_name; +} +void Zombie::announce() const +{ + std::cout << name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl; +} diff --git a/ex01/src/main.cpp b/ex01/src/main.cpp new file mode 100644 index 0000000..12b9397 --- /dev/null +++ b/ex01/src/main.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* main.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:05:08 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include "Zombie.hpp" + +int main() +{ + Zombie *horde = zombieHorde(5, "One of the horde"); + for (int i = 0; i < 5; i++) + { + horde[i].announce(); + } + delete[] horde; + std::cout << "The world is saved, the zombies are destroyed!" << std::endl; + return (0); +} \ No newline at end of file diff --git a/ex01/src/zombieHorde.cpp b/ex01/src/zombieHorde.cpp new file mode 100644 index 0000000..5d873b1 --- /dev/null +++ b/ex01/src/zombieHorde.cpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* zombieHorde.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 15:59:16 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:02:56 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" + +Zombie* zombieHorde( int N, std::string name ) +{ + Zombie* horde = new Zombie[N]; + for (int i = 0; i < N; i++) + { + horde[i].setName(name); + } + return (horde); +} diff --git a/ex02/Makefile b/ex02/Makefile new file mode 100644 index 0000000..a98168e --- /dev/null +++ b/ex02/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 16:06:00 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = Brain +SRC = main.cpp + +-include ../common.mk + diff --git a/ex02/src/main.cpp b/ex02/src/main.cpp new file mode 100644 index 0000000..58d3aa1 --- /dev/null +++ b/ex02/src/main.cpp @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* main.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:06:06 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:12:28 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int main() +{ + std::string string = "HI THIS IS BRAIN"; + std::string *stringPTR = &string; + std::string &stringREF = string; + + std::cout << "Address of the string: " << &string << std::endl; + std::cout << "Address held by stringPTR: " << stringPTR << std::endl; + std::cout << "Address held by (of) stringREF: " << &stringREF << std::endl; + + std::cout << "Value of string: " << string << std::endl; + std::cout << "Value pointed bystringPTR: " << *stringPTR << std::endl; + std::cout << "Value of stringREF: " << stringREF << std::endl; +} \ No newline at end of file diff --git a/ex03/Makefile b/ex03/Makefile new file mode 100644 index 0000000..d0e92a7 --- /dev/null +++ b/ex03/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 16:15:16 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = Violence +SRC = HumanA.cpp HumanB.cpp Weapon.cpp main.cpp + +-include ../common.mk + diff --git a/ex03/inc/HumanA.hpp b/ex03/inc/HumanA.hpp new file mode 100644 index 0000000..1f55cfa --- /dev/null +++ b/ex03/inc/HumanA.hpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* HumanA.hpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:28:57 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:57:56 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include "Weapon.hpp" + +class HumanA +{ +private: + std::string name; + Weapon *weapon; + HumanA(); + +public: + HumanA(std::string p_name, Weapon &p_weapon); + void attack(); +}; \ No newline at end of file diff --git a/ex03/inc/HumanB.hpp b/ex03/inc/HumanB.hpp new file mode 100644 index 0000000..e48de70 --- /dev/null +++ b/ex03/inc/HumanB.hpp @@ -0,0 +1,16 @@ + +#include +#include "Weapon.hpp" + +class HumanB +{ +private: + std::string name; + Weapon *weapon; + HumanB(); + +public: + HumanB(std::string p_name); + void attack(); + void setWeapon(Weapon &p_weapon); +}; \ No newline at end of file diff --git a/ex03/inc/Weapon.hpp b/ex03/inc/Weapon.hpp new file mode 100644 index 0000000..a53c633 --- /dev/null +++ b/ex03/inc/Weapon.hpp @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Weapon.hpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:15:25 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:28:51 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +class Weapon +{ +public: + Weapon(); + Weapon(std::string p_type); + ~Weapon(); + const std::string & getType(); + void setType(std::string p_type); + +private: + std::string type; +}; \ No newline at end of file diff --git a/ex03/src/HumanA.cpp b/ex03/src/HumanA.cpp new file mode 100644 index 0000000..e6eba99 --- /dev/null +++ b/ex03/src/HumanA.cpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* HumanA.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:48:35 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:58:14 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + + +#include +#include +#include "Weapon.hpp" +#include "HumanA.hpp" + + +HumanA::HumanA(std::string p_name, Weapon &p_weapon) +{ + name = p_name; + weapon = &p_weapon; +} +void HumanA::attack() +{ + std::cout << name << " attacks with " << (*weapon).getType() << std::endl; +} + + + diff --git a/ex03/src/HumanB.cpp b/ex03/src/HumanB.cpp new file mode 100644 index 0000000..ca5c927 --- /dev/null +++ b/ex03/src/HumanB.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* HumanB.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:49:44 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:54:09 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include "Weapon.hpp" +#include "HumanB.hpp" + +HumanB::HumanB(std::string p_name) +{ + name = p_name; + weapon = nullptr; +} + +void HumanB::attack() +{ + std::cout << name << " attacks with " << (*weapon).getType() << std::endl; +} + +void HumanB::setWeapon(Weapon &p_weapon) +{ + weapon = &p_weapon; +} + + + diff --git a/ex03/src/Weapon.cpp b/ex03/src/Weapon.cpp new file mode 100644 index 0000000..e3a717d --- /dev/null +++ b/ex03/src/Weapon.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Weapon.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:23:32 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:55:24 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include +#include "Weapon.hpp" + +Weapon::Weapon() +{ + type = ""; +} +Weapon::Weapon(std::string p_type) +{ + type = p_type; +} +Weapon::~Weapon() +{ + std::cout << type << " is destroyed!" << std::endl; +} +const std::string & Weapon::Weapon::getType() +{ + return (type); +} +void Weapon::setType(std::string p_type) +{ + type = p_type; +} \ No newline at end of file diff --git a/ex03/src/main.cpp b/ex03/src/main.cpp new file mode 100644 index 0000000..ff832b2 --- /dev/null +++ b/ex03/src/main.cpp @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* main.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/21 16:21:48 by whaffman #+# #+# */ +/* Updated: 2025/03/21 16:29:32 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "HumanA.hpp" +#include "HumanB.hpp" +#include "Weapon.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; +} \ No newline at end of file diff --git a/ex04/Makefile b/ex04/Makefile new file mode 100644 index 0000000..730a48b --- /dev/null +++ b/ex04/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 15:17:22 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = +SRC = + +-include ../common.mk + diff --git a/ex05/Makefile b/ex05/Makefile new file mode 100644 index 0000000..730a48b --- /dev/null +++ b/ex05/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 15:17:22 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = +SRC = + +-include ../common.mk + diff --git a/ex06/Makefile b/ex06/Makefile new file mode 100644 index 0000000..730a48b --- /dev/null +++ b/ex06/Makefile @@ -0,0 +1,17 @@ +# **************************************************************************** # +# # +# :::::::: # +# Makefile :+: :+: # +# +:+ # +# By: whaffman +#+ # +# +#+ # +# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # +# Updated: 2025/03/21 15:17:22 by whaffman ######## odam.nl # +# # +# **************************************************************************** # + +NAME = +SRC = + +-include ../common.mk +