somewhere in ex03
This commit is contained in:
parent
3650931e58
commit
5cef88bae1
17
ex00/Makefile
Normal file
17
ex00/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
31
ex00/inc/Zombie.hpp
Normal file
31
ex00/inc/Zombie.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Zombie.hpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 15:30:14 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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 );
|
||||||
35
ex00/src/Zombie.cpp
Normal file
35
ex00/src/Zombie.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Zombie.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 15:21:44 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 15:27:56 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
22
ex00/src/main.cpp
Normal file
22
ex00/src/main.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* main.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
19
ex00/src/newZombie.cpp
Normal file
19
ex00/src/newZombie.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* newZombie.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
19
ex00/src/randomChump.cpp
Normal file
19
ex00/src/randomChump.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* randomChump.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* 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();
|
||||||
|
}
|
||||||
17
ex01/Makefile
Normal file
17
ex01/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
30
ex01/inc/Zombie.hpp
Normal file
30
ex01/inc/Zombie.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Zombie.hpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 15:59:48 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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 );
|
||||||
35
ex01/src/Zombie.cpp
Normal file
35
ex01/src/Zombie.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Zombie.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 15:21:44 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 15:59:53 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
26
ex01/src/main.cpp
Normal file
26
ex01/src/main.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* main.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:05:08 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#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);
|
||||||
|
}
|
||||||
23
ex01/src/zombieHorde.cpp
Normal file
23
ex01/src/zombieHorde.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* zombieHorde.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
17
ex02/Makefile
Normal file
17
ex02/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
29
ex02/src/main.cpp
Normal file
29
ex02/src/main.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* main.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:06:06 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:12:28 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
17
ex03/Makefile
Normal file
17
ex03/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
26
ex03/inc/HumanA.hpp
Normal file
26
ex03/inc/HumanA.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* HumanA.hpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:28:57 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:57:56 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "Weapon.hpp"
|
||||||
|
|
||||||
|
class HumanA
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
Weapon *weapon;
|
||||||
|
HumanA();
|
||||||
|
|
||||||
|
public:
|
||||||
|
HumanA(std::string p_name, Weapon &p_weapon);
|
||||||
|
void attack();
|
||||||
|
};
|
||||||
16
ex03/inc/HumanB.hpp
Normal file
16
ex03/inc/HumanB.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include <string>
|
||||||
|
#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);
|
||||||
|
};
|
||||||
28
ex03/inc/Weapon.hpp
Normal file
28
ex03/inc/Weapon.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Weapon.hpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:15:25 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:28:51 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Weapon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Weapon();
|
||||||
|
Weapon(std::string p_type);
|
||||||
|
~Weapon();
|
||||||
|
const std::string & getType();
|
||||||
|
void setType(std::string p_type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string type;
|
||||||
|
};
|
||||||
31
ex03/src/HumanA.cpp
Normal file
31
ex03/src/HumanA.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* HumanA.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:48:35 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:58:14 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
35
ex03/src/HumanB.cpp
Normal file
35
ex03/src/HumanB.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* HumanB.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:49:44 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:54:09 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
35
ex03/src/Weapon.cpp
Normal file
35
ex03/src/Weapon.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* Weapon.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2025/03/21 16:23:32 by whaffman #+# #+# */
|
||||||
|
/* Updated: 2025/03/21 16:55:24 by whaffman ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
35
ex03/src/main.cpp
Normal file
35
ex03/src/main.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* main.cpp :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
17
ex04/Makefile
Normal file
17
ex04/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
17
ex05/Makefile
Normal file
17
ex05/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
17
ex06/Makefile
Normal file
17
ex06/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# :::::::: #
|
||||||
|
# Makefile :+: :+: #
|
||||||
|
# +:+ #
|
||||||
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
|
# +#+ #
|
||||||
|
# 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
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user