init: ex00-02
This commit is contained in:
19
ex00/src/Zombie.cpp
Normal file
19
ex00/src/Zombie.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "Zombie.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
Zombie::Zombie(std::string name)
|
||||
{
|
||||
this->name = name;
|
||||
std::cout << this->name << ": " << "Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
Zombie::~Zombie()
|
||||
{
|
||||
std::cout << this->name << ": " << "~Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
void Zombie::announce() const
|
||||
{
|
||||
std::cout << this->name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl;
|
||||
}
|
18
ex00/src/Zombie.hpp
Normal file
18
ex00/src/Zombie.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <string>
|
||||
|
||||
class Zombie {
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
Zombie(std::string name);
|
||||
~Zombie();
|
||||
|
||||
void announce(void) const;
|
||||
void setName(std::string name);
|
||||
|
||||
};
|
||||
|
||||
Zombie* newZombie(std::string name);
|
||||
void randomChump(std::string name);
|
12
ex00/src/main.cpp
Normal file
12
ex00/src/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "Zombie.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
Zombie* jean;
|
||||
Zombie pierre("Pierre");
|
||||
|
||||
jean = new Zombie("jean");
|
||||
jean->announce();
|
||||
delete jean;
|
||||
randomChump("francois");
|
||||
}
|
9
ex00/src/newZombie.cpp
Normal file
9
ex00/src/newZombie.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "Zombie.hpp"
|
||||
|
||||
Zombie* newZombie(std::string name)
|
||||
{
|
||||
Zombie* zombie;
|
||||
|
||||
zombie = new Zombie(name);
|
||||
return (zombie);
|
||||
}
|
8
ex00/src/randomChump.cpp
Normal file
8
ex00/src/randomChump.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "Zombie.hpp"
|
||||
|
||||
void randomChump(std::string name)
|
||||
{
|
||||
Zombie zombie(name);
|
||||
|
||||
zombie.announce();
|
||||
}
|
Reference in New Issue
Block a user