Compare commits
14 Commits
095cc3dc18
...
master
Author | SHA1 | Date | |
---|---|---|---|
35cbcfd02d | |||
cebe9f6ea7 | |||
cc5928a671 | |||
5522ebf3ba | |||
a7e4a9cd75 | |||
7a10311d56 | |||
42a06c46cd | |||
efa91c0cb5 | |||
eb2b035b75 | |||
636365d65c | |||
5d687d7c28 | |||
3ef324e5e1 | |||
98ece4839e | |||
76d822b831 |
@ -13,23 +13,12 @@ Zombie::Zombie(const std::string& name)
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
Zombie::Zombie(const Zombie& src)
|
||||
{
|
||||
*this = src;
|
||||
}
|
||||
|
||||
Zombie::~Zombie()
|
||||
{
|
||||
std::cout << "~Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
Zombie& Zombie::operator=(const Zombie& src)
|
||||
{
|
||||
this->_name = src._name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Zombie::announe()
|
||||
void Zombie::announce()
|
||||
{
|
||||
std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl;
|
||||
}
|
||||
|
@ -8,14 +8,11 @@ class Zombie
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
Zombie(const Zombie& src);
|
||||
Zombie();
|
||||
Zombie(const std::string& name);
|
||||
Zombie();
|
||||
~Zombie();
|
||||
|
||||
Zombie& operator=(const Zombie& src);
|
||||
|
||||
void announe(void);
|
||||
void announce(void);
|
||||
};
|
||||
|
||||
void randomChump(std::string name);
|
||||
|
@ -3,10 +3,10 @@
|
||||
int main()
|
||||
{
|
||||
Zombie* jean = newZombie("jean");
|
||||
jean->announe();
|
||||
jean->announce();
|
||||
delete jean;
|
||||
|
||||
Zombie no_name;
|
||||
no_name.announe();
|
||||
no_name.announce();
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
void randomChump(std::string name)
|
||||
{
|
||||
Zombie zombie(name);
|
||||
zombie.announe();
|
||||
zombie.announce();
|
||||
}
|
||||
|
@ -13,23 +13,12 @@ Zombie::Zombie(const std::string& name)
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
Zombie::Zombie(const Zombie& src)
|
||||
{
|
||||
*this = src;
|
||||
}
|
||||
|
||||
Zombie::~Zombie()
|
||||
{
|
||||
std::cout << "~Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
Zombie& Zombie::operator=(const Zombie& src)
|
||||
{
|
||||
this->_name = src._name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Zombie::announe()
|
||||
void Zombie::announce()
|
||||
{
|
||||
std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl;
|
||||
}
|
||||
|
@ -8,14 +8,11 @@ class Zombie
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
Zombie(const Zombie& src);
|
||||
Zombie();
|
||||
Zombie(const std::string& name);
|
||||
~Zombie();
|
||||
|
||||
Zombie& operator=(const Zombie& src);
|
||||
|
||||
void announe(void);
|
||||
void announce(void);
|
||||
void setName(const std::string& name);
|
||||
};
|
||||
|
||||
|
@ -1,15 +1,17 @@
|
||||
#include "Zombie.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
Zombie* jean = zombieHorde(2, "jean");
|
||||
delete[] jean;
|
||||
|
||||
Zombie* bob = zombieHorde(-1, "bob");
|
||||
if (bob == NULL)
|
||||
return 1;
|
||||
bob->announe();
|
||||
Zombie* bob = zombieHorde(4, "bob");
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
bob[i].announce();
|
||||
delete[] bob;
|
||||
|
||||
Zombie* pierre = zombieHorde(-1, "pierre");
|
||||
if (pierre == NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,9 +7,6 @@ Zombie* zombieHorde(int N, std::string name)
|
||||
return NULL;
|
||||
Zombie* zombies = new Zombie[N];
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
zombies[i].setName(name);
|
||||
zombies[i].announe();
|
||||
}
|
||||
return zombies;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ CXX = c++
|
||||
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
NAME = ex00
|
||||
NAME = ex02
|
||||
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||
|
@ -1,25 +1,25 @@
|
||||
CXX = c++
|
||||
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -g -O0
|
||||
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
BINDIR = bin
|
||||
EXECUTABLE = Weapon
|
||||
NAME = ex03
|
||||
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||
|
||||
all: $(BINDIR)/$(EXECUTABLE)
|
||||
all: $(NAME)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
mkdir -p obj
|
||||
$(CXX) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(BINDIR)/$(EXECUTABLE): $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $^ -o $@
|
||||
$(NAME): $(OBJS)
|
||||
$(CXX) $(CPPFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)/*.o
|
||||
|
||||
fclean: clean
|
||||
rm -fr $(BINDIR)/$(EXECUTABLE)
|
||||
rm -fr $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
@ -1,17 +1,21 @@
|
||||
#include "HumanA.hpp"
|
||||
#include "Weapon.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
HumanA::HumanA(std::string name, Weapon &weapon) : weapon(weapon)
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
HumanA::HumanA(const std::string& name, const Weapon& weapon):
|
||||
_weapon(weapon)
|
||||
{
|
||||
this->name = name;
|
||||
this->_name = name;
|
||||
std::cout << "HumanA()" << std::endl;
|
||||
}
|
||||
|
||||
HumanA::~HumanA()
|
||||
{}
|
||||
{
|
||||
std::cout << "~HumanA()" << std::endl;
|
||||
}
|
||||
|
||||
void HumanA::attack()
|
||||
{
|
||||
std::cout << this->name << " attacks with their " << this->weapon.getType() << std::endl;
|
||||
std::cout << this->_name << " attacks with their " << this->_weapon.getType() << std::endl;
|
||||
}
|
||||
|
@ -1,19 +1,18 @@
|
||||
#ifndef HUMANA_HPP
|
||||
# define HUMANA_HPP
|
||||
#pragma once
|
||||
|
||||
#include "Weapon.hpp"
|
||||
#include <string>
|
||||
|
||||
class HumanA
|
||||
{
|
||||
private:
|
||||
Weapon &weapon;
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
HumanA(std::string name, Weapon &weapon);
|
||||
HumanA(const std::string& name, const Weapon& weapon);
|
||||
~HumanA();
|
||||
|
||||
void attack();
|
||||
};
|
||||
|
||||
#endif
|
||||
private:
|
||||
const Weapon& _weapon;
|
||||
std::string _name;
|
||||
|
||||
};
|
||||
|
@ -1,29 +1,33 @@
|
||||
#include "HumanB.hpp"
|
||||
#include "Weapon.hpp"
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
HumanB::HumanB(std::string name)
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
HumanB::HumanB(const std::string& name)
|
||||
{
|
||||
this->weapon = NULL;
|
||||
this->name = name;
|
||||
std::cout << "HumanB()" << std::endl;
|
||||
this->_name = name;
|
||||
this->_weapon = NULL;
|
||||
}
|
||||
|
||||
HumanB::~HumanB()
|
||||
{}
|
||||
{
|
||||
std::cout << "~HumanB()" << std::endl;
|
||||
}
|
||||
|
||||
void HumanB::attack()
|
||||
{
|
||||
if (this->weapon == NULL)
|
||||
{
|
||||
std::cerr << this->name << " can't attack without weapon" << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << this->name << " attacks with their " << this->weapon->getType() << std::endl;
|
||||
std::cout << this->_name << " attacks with their ";
|
||||
if (this->_weapon == NULL)
|
||||
std::cout << "hands";
|
||||
else
|
||||
std::cout << this->_weapon->getType();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void HumanB::setWeapon(Weapon& new_weapon)
|
||||
void HumanB::setWeapon(const Weapon &weapon)
|
||||
{
|
||||
this->weapon = &new_weapon;
|
||||
this->_weapon = &weapon;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
#ifndef HUMANB_HPP
|
||||
# define HUMANB_HPP
|
||||
#pragma once
|
||||
|
||||
#include "Weapon.hpp"
|
||||
#include <string>
|
||||
|
||||
class HumanB
|
||||
{
|
||||
private:
|
||||
Weapon* weapon;
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
HumanB(std::string name);
|
||||
HumanB(const std::string& name);
|
||||
~HumanB();
|
||||
|
||||
void setWeapon(Weapon& new_weapon);
|
||||
void attack();
|
||||
void setWeapon(const Weapon& weapon);
|
||||
|
||||
private:
|
||||
const Weapon* _weapon;
|
||||
std::string _name;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
@ -1,24 +1,42 @@
|
||||
#include "Weapon.hpp"
|
||||
#include <string>
|
||||
|
||||
Weapon::Weapon(std::string type)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
Weapon::Weapon()
|
||||
{
|
||||
std::cout << "Weapon()" << std::endl;
|
||||
}
|
||||
|
||||
Weapon::Weapon(const Weapon& src)
|
||||
{
|
||||
std::cout << "Weapon()" << std::endl;
|
||||
this->_type = src._type;
|
||||
}
|
||||
|
||||
Weapon::Weapon(const std::string& type)
|
||||
{
|
||||
std::cout << "Weapon()" << std::endl;
|
||||
this->_type = type;
|
||||
}
|
||||
|
||||
Weapon::~Weapon()
|
||||
{}
|
||||
|
||||
std::string Weapon::getType()
|
||||
{
|
||||
return (this->type);
|
||||
std::cout << "~Weapon()" << std::endl;
|
||||
}
|
||||
|
||||
void Weapon::setType(std::string new_type)
|
||||
Weapon& Weapon::operator=(const Weapon &src)
|
||||
{
|
||||
this->type = new_type;
|
||||
this->_type = src._type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Weapon::setType(const std::string& newType)
|
||||
{
|
||||
this->_type = newType;
|
||||
}
|
||||
|
||||
const std::string& Weapon::getType() const
|
||||
{
|
||||
return this->_type;
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
#ifndef WEAPON_HPP
|
||||
# define WEAPON_HPP
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Weapon
|
||||
{
|
||||
private:
|
||||
std::string type;
|
||||
|
||||
public:
|
||||
Weapon(std::string type);
|
||||
Weapon();
|
||||
Weapon(const Weapon& src);
|
||||
Weapon(const std::string& type);
|
||||
~Weapon();
|
||||
|
||||
std::string getType();
|
||||
void setType(std::string new_type);
|
||||
Weapon& operator=(const Weapon& src);
|
||||
|
||||
const std::string& getType() const;
|
||||
void setType(const std::string& newType);
|
||||
|
||||
private:
|
||||
std::string _type;
|
||||
};
|
||||
#endif
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "Weapon.hpp"
|
||||
#include "HumanA.hpp"
|
||||
#include "HumanB.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -19,5 +17,7 @@ int main()
|
||||
club.setType("some other type of club");
|
||||
jim.attack();
|
||||
}
|
||||
HumanB jim("Jim");
|
||||
jim.attack();
|
||||
return 0;
|
||||
}
|
||||
|
25
ex04/Makefile
Normal file
25
ex04/Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
CXX = c++
|
||||
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
NAME = sed
|
||||
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
mkdir -p obj
|
||||
$(CXX) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
$(CXX) $(CPPFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)/*.o
|
||||
|
||||
fclean: clean
|
||||
rm -fr $(NAME)
|
||||
|
||||
re: fclean all
|
@ -8,17 +8,13 @@
|
||||
static int get_text(const char *path, std::string &text)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
std::string line;
|
||||
|
||||
if (!file.is_open())
|
||||
{
|
||||
std::cerr << "sed: file error" << std::endl;
|
||||
return (1);
|
||||
}
|
||||
while (std::getline(file, line))
|
||||
text += line + "\n";
|
||||
if (text.size() != 0)
|
||||
text.erase(text.size() - 1);
|
||||
std::getline(file, text, '\0');
|
||||
file.close();
|
||||
return (0);
|
||||
}
|
||||
@ -60,7 +56,12 @@ int main(int ac, char **av)
|
||||
}
|
||||
if (get_text(av[1], text))
|
||||
return (2);
|
||||
std::cout << text << std::endl;
|
||||
replaced = replace_text(text.c_str(), av[2], av[3]);
|
||||
std::cout << replaced << std::endl;
|
||||
std::ofstream file((std::string(av[1]) + std::string(".replace")).c_str());
|
||||
if (!file.is_open())
|
||||
{
|
||||
std::cerr << "sed: file error" << std::endl;
|
||||
return (1);
|
||||
}
|
||||
file << replaced;
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
CXX = c++
|
||||
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -g -O0
|
||||
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
BINDIR = bin
|
||||
EXECUTABLE = harl
|
||||
NAME = ex05
|
||||
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||
|
||||
all: $(BINDIR)/$(EXECUTABLE)
|
||||
all: $(NAME)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
mkdir -p obj
|
||||
$(CXX) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(BINDIR)/$(EXECUTABLE): $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $^ -o $@
|
||||
$(NAME): $(OBJS)
|
||||
$(CXX) $(CPPFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)/*.o
|
||||
|
||||
fclean: clean
|
||||
rm -fr $(BINDIR)/$(EXECUTABLE)
|
||||
rm -fr $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "Harl.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void Harl::complain(std::string level)
|
||||
{
|
||||
@ -26,22 +25,22 @@ void Harl::complain(std::string level)
|
||||
}
|
||||
}
|
||||
|
||||
void Harl::debug() const
|
||||
void Harl::debug()
|
||||
{
|
||||
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do !" << std::endl;
|
||||
}
|
||||
|
||||
void Harl::info() const
|
||||
void Harl::info()
|
||||
{
|
||||
std::cout << "I cannot believe adding extra bacon costs more money. You didn’t put enough bacon in my burger ! If you did, I wouldn’t be asking for more !" << std::endl;
|
||||
}
|
||||
|
||||
void Harl::warning() const
|
||||
void Harl::warning()
|
||||
{
|
||||
std::cout << "I think I deserve to have some extra bacon for free. I’ve been coming for years whereas you started working here since last month." << std::endl;
|
||||
}
|
||||
|
||||
void Harl::error() const
|
||||
void Harl::error()
|
||||
{
|
||||
std::cout << "This is unacceptable ! I want to speak to the manager now." << std::endl;
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Harl
|
||||
{
|
||||
private:
|
||||
void debug() const;
|
||||
void info() const;
|
||||
void warning() const;
|
||||
void error() const;
|
||||
void debug();
|
||||
void info();
|
||||
void warning();
|
||||
void error();
|
||||
|
||||
public:
|
||||
void complain(std::string level);
|
||||
};
|
||||
|
||||
typedef void (Harl::*HarlMethod)() const;
|
||||
typedef void (Harl::*HarlMethod)();
|
||||
|
@ -1,25 +1,25 @@
|
||||
CXX = c++
|
||||
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -g -O0
|
||||
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
BINDIR = bin
|
||||
EXECUTABLE = harl
|
||||
NAME = ex06
|
||||
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||
|
||||
all: $(BINDIR)/$(EXECUTABLE)
|
||||
all: $(NAME)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
mkdir -p obj
|
||||
$(CXX) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(BINDIR)/$(EXECUTABLE): $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $^ -o $@
|
||||
$(NAME): $(OBJS)
|
||||
$(CXX) $(CPPFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)/*.o
|
||||
|
||||
fclean: clean
|
||||
rm -fr $(BINDIR)/$(EXECUTABLE)
|
||||
rm -fr $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
@ -1,47 +1,51 @@
|
||||
#include "Harl.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void Harl::complain(std::string level)
|
||||
{
|
||||
static const HarlMethod methods[4] = {
|
||||
&Harl::debug,
|
||||
&Harl::info,
|
||||
&Harl::warning,
|
||||
&Harl::error,
|
||||
};
|
||||
static const std::string strings[4] = {
|
||||
"DEBUG",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"ERROR"
|
||||
};
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < 4; i++)
|
||||
if (strings[i] == level)
|
||||
{
|
||||
(this->*methods[i])();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
switch(i) {
|
||||
case 0:
|
||||
debug();
|
||||
case 1:
|
||||
info();
|
||||
case 2:
|
||||
warning();
|
||||
case 3:
|
||||
error();
|
||||
break;
|
||||
default:
|
||||
std::cout << "Not a level" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Harl::debug() const
|
||||
void Harl::debug()
|
||||
{
|
||||
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do !" << std::endl;
|
||||
}
|
||||
|
||||
void Harl::info() const
|
||||
void Harl::info()
|
||||
{
|
||||
std::cout << "I cannot believe adding extra bacon costs more money. You didn’t put enough bacon in my burger ! If you did, I wouldn’t be asking for more !" << std::endl;
|
||||
}
|
||||
|
||||
void Harl::warning() const
|
||||
void Harl::warning()
|
||||
{
|
||||
std::cout << "I think I deserve to have some extra bacon for free. I’ve been coming for years whereas you started working here since last month." << std::endl;
|
||||
}
|
||||
|
||||
void Harl::error() const
|
||||
void Harl::error()
|
||||
{
|
||||
std::cout << "This is unacceptable ! I want to speak to the manager now." << std::endl;
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Harl
|
||||
{
|
||||
private:
|
||||
void debug() const;
|
||||
void info() const;
|
||||
void warning() const;
|
||||
void error() const;
|
||||
void debug();
|
||||
void info();
|
||||
void warning();
|
||||
void error();
|
||||
|
||||
public:
|
||||
void complain(std::string level);
|
||||
};
|
||||
|
||||
typedef void (Harl::*HarlMethod)() const;
|
||||
typedef void (Harl::*HarlMethod)();
|
||||
|
@ -1,28 +1,10 @@
|
||||
#include "Harl.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(int ac, char **av)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc <= 1)
|
||||
return 1;
|
||||
Harl harl;
|
||||
static const std::string levels[] = {
|
||||
"DEBUG",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"GOLEM",
|
||||
"ERROR",
|
||||
"PASLU",
|
||||
"FLEMME",
|
||||
"PANIC"
|
||||
};
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
if (ac > 1 && levels[i] != av[1])
|
||||
harl.complain(levels[i]);
|
||||
else
|
||||
{
|
||||
std::cerr << "ERROR" << std::endl;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
harl.complain(argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user