better
This commit is contained in:
parent
e857218775
commit
0700c0e42b
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 15:30:14 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:43:54 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -25,7 +25,6 @@ public:
|
|||||||
~Zombie();
|
~Zombie();
|
||||||
void announce();
|
void announce();
|
||||||
void setName(std::string name);
|
void setName(std::string name);
|
||||||
|
static Zombie *newZombie(std::string name);
|
||||||
|
static void randomChump(std::string name);
|
||||||
};
|
};
|
||||||
|
|
||||||
Zombie* newZombie( std::string name );
|
|
||||||
void randomChump( std::string name );
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 15:33:25 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:45:10 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Zombie* zombie = newZombie("Alice");
|
Zombie* zombie = Zombie::newZombie("Alice");
|
||||||
zombie->announce();
|
zombie->announce();
|
||||||
randomChump("Bob");
|
Zombie::randomChump("Bob");
|
||||||
delete zombie;
|
delete zombie;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -6,13 +6,13 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:30:53 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:30:53 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 15:31:04 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:44:28 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Zombie.hpp"
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
Zombie* newZombie(std::string name)
|
Zombie* Zombie::newZombie(std::string name)
|
||||||
{
|
{
|
||||||
Zombie* zombie = new Zombie(name);
|
Zombie* zombie = new Zombie(name);
|
||||||
return (zombie);
|
return (zombie);
|
||||||
|
|||||||
@ -6,13 +6,13 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:30:21 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:30:21 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 15:30:49 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:44:34 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Zombie.hpp"
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
void randomChump(std::string name)
|
void Zombie::randomChump(std::string name)
|
||||||
{
|
{
|
||||||
Zombie zombie(name);
|
Zombie zombie(name);
|
||||||
zombie.announce();
|
zombie.announce();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:19:56 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 15:59:48 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:48:04 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -25,6 +25,8 @@ public:
|
|||||||
~Zombie();
|
~Zombie();
|
||||||
void announce() const;
|
void announce() const;
|
||||||
void setName(std::string name);
|
void setName(std::string name);
|
||||||
|
|
||||||
|
static Zombie *zombieHorde(int N, std::string name);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Zombie* zombieHorde( int N, std::string name );
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:31:11 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 16:05:08 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:48:25 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Zombie *horde = zombieHorde(5, "One of the horde");
|
Zombie *horde = Zombie::zombieHorde(5, "One of the horde");
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
horde[i].announce();
|
horde[i].announce();
|
||||||
|
|||||||
@ -6,13 +6,13 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 15:59:16 by whaffman #+# #+# */
|
/* Created: 2025/03/21 15:59:16 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 16:02:56 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:48:14 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Zombie.hpp"
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
Zombie* zombieHorde( int N, std::string name )
|
Zombie* Zombie::zombieHorde( int N, std::string name )
|
||||||
{
|
{
|
||||||
Zombie* horde = new Zombie[N];
|
Zombie* horde = new Zombie[N];
|
||||||
for (int i = 0; i < N; i++)
|
for (int i = 0; i < N; i++)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 16:28:57 by whaffman #+# #+# */
|
/* Created: 2025/03/21 16:28:57 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 16:57:56 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:56:49 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class HumanA
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
Weapon *weapon;
|
Weapon &weapon;
|
||||||
HumanA();
|
HumanA();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -6,26 +6,19 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 16:48:35 by whaffman #+# #+# */
|
/* Created: 2025/03/21 16:48:35 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 16:58:14 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 10:57:31 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Weapon.hpp"
|
#include "Weapon.hpp"
|
||||||
#include "HumanA.hpp"
|
#include "HumanA.hpp"
|
||||||
|
|
||||||
|
HumanA::HumanA(std::string p_name, Weapon &p_weapon) : name(p_name), weapon(p_weapon)
|
||||||
HumanA::HumanA(std::string p_name, Weapon &p_weapon)
|
|
||||||
{
|
{
|
||||||
name = p_name;
|
|
||||||
weapon = &p_weapon;
|
|
||||||
}
|
}
|
||||||
void HumanA::attack()
|
void HumanA::attack()
|
||||||
{
|
{
|
||||||
std::cout << name << " attacks with " << (*weapon).getType() << std::endl;
|
std::cout << name << " attacks with " << (weapon).getType() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/21 16:21:48 by whaffman #+# #+# */
|
/* Created: 2025/03/21 16:21:48 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/21 16:29:32 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 11:14:23 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,18 +17,18 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Weapon club = Weapon("crude spiked club");
|
Weapon club = Weapon("a banana");
|
||||||
HumanA bob("Bob", club);
|
HumanA bob("Bob", club);
|
||||||
bob.attack();
|
bob.attack();
|
||||||
club.setType("some other type of club");
|
club.setType("two pears on a string");
|
||||||
bob.attack();
|
bob.attack();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Weapon club = Weapon("crude spiked club");
|
Weapon club = Weapon("a poisended apple");
|
||||||
HumanB jim("Jim");
|
HumanB jim("Jim");
|
||||||
jim.setWeapon(club);
|
jim.setWeapon(club);
|
||||||
jim.attack();
|
jim.attack();
|
||||||
club.setType("some other type of club");
|
club.setType("slippery jelly");
|
||||||
jim.attack();
|
jim.attack();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 13:59:46 by whaffman #+# #+# */
|
/* Created: 2025/03/23 13:59:46 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/23 14:28:19 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 11:20:09 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -24,18 +24,27 @@ int main(int argc, char *argv[])
|
|||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
|
{
|
||||||
std::cout << "Usage: ./Replacer <filename> <old string> <new string>" << std::endl;
|
std::cout << "Usage: ./Replacer <filename> <old string> <new string>" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
inFile.open(argv[1], std::ios::in);
|
inFile.open(argv[1], std::ios::in);
|
||||||
if (!inFile.is_open())
|
if (!inFile.is_open())
|
||||||
|
{
|
||||||
std::cout << "Can't open In file" << std::endl;
|
std::cout << "Can't open In file" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
outFileName = argv[1];
|
outFileName = argv[1];
|
||||||
outFileName += ".replace";
|
outFileName += ".replace";
|
||||||
outFile.open(outFileName, std::ios::out);
|
outFile.open(outFileName, std::ios::out);
|
||||||
if (!outFile.is_open())
|
if (!outFile.is_open())
|
||||||
|
{
|
||||||
std::cout << "Can't open OUT file" << std::endl;
|
std::cout << "Can't open OUT file" << std::endl;
|
||||||
|
inFile.close();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
Replacer replacer(argv[2], argv[3]);
|
Replacer replacer(argv[2], argv[3]);
|
||||||
|
|
||||||
while (std::getline(inFile, line))
|
while (std::getline(inFile, line))
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */
|
/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/23 15:35:07 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 11:26:20 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,12 +15,13 @@
|
|||||||
class Harl
|
class Harl
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string levels[4];
|
static std::string levels[4];
|
||||||
void (Harl::*levelFunc[4])();
|
static void (Harl::*levelFunc[4])();
|
||||||
void info();
|
void info();
|
||||||
void debug();
|
void debug();
|
||||||
void warning();
|
void warning();
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Harl();
|
Harl();
|
||||||
~Harl();
|
~Harl();
|
||||||
|
|||||||
@ -6,46 +6,41 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 15:09:28 by whaffman #+# #+# */
|
/* Created: 2025/03/23 15:09:28 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/23 15:44:03 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 12:27:45 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Harl.hpp"
|
#include "Harl.hpp"
|
||||||
|
|
||||||
|
std::string Harl::levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
|
||||||
|
void (Harl::*Harl::levelFunc[4])() = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
|
||||||
|
|
||||||
Harl::Harl()
|
Harl::Harl()
|
||||||
{
|
{
|
||||||
levels[0] = "DEBUG";
|
|
||||||
levels[1] = "INFO";
|
|
||||||
levels[2] = "WARNING";
|
|
||||||
levels[3] = "ERROR";
|
|
||||||
levelFunc[0] = &Harl::debug;
|
|
||||||
levelFunc[1] = &Harl::info;
|
|
||||||
levelFunc[2] = &Harl::warning;
|
|
||||||
levelFunc[3] = &Harl::error;
|
|
||||||
}
|
}
|
||||||
Harl::~Harl() {}
|
Harl::~Harl() {}
|
||||||
|
|
||||||
void Harl::debug()
|
void Harl::debug()
|
||||||
{
|
{
|
||||||
std::cout << "[DEBUG]" << std::endl;
|
std::cout << "[DEBUG]" << std::endl;
|
||||||
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!" << std::endl;
|
std::cout << "I put butter in the pan, to fry an egg." << std::endl;
|
||||||
}
|
}
|
||||||
void Harl::info()
|
void Harl::info()
|
||||||
{
|
{
|
||||||
std::cout << "[INFO]" << std::endl;
|
std::cout << "[INFO]" << std::endl;
|
||||||
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;
|
std::cout << "Tiny bubbles are appearing, the butter is Hot" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::warning()
|
void Harl::warning()
|
||||||
{
|
{
|
||||||
std::cout << "[WARNING]" << std::endl;
|
std::cout << "[WARNING]" << std::endl;
|
||||||
std::cout << "I think I deserve to have some extra bacon for free. I’ve been coming for years, whereas you started working here just last month." << std::endl;
|
std::cout << "The butter turns brown, It's really time to put in the eggs" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::error()
|
void Harl::error()
|
||||||
{
|
{
|
||||||
std::cout << "[ERROR]" << std::endl;
|
std::cout << "[ERROR]" << std::endl;
|
||||||
std::cout << "This is unacceptable! I want to speak to the manager now." << std::endl;
|
std::cout << "Too late, your house is on fire!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::complain(std::string level)
|
void Harl::complain(std::string level)
|
||||||
@ -58,5 +53,5 @@ void Harl::complain(std::string level)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "I don't know anymorre what to complain about" << std::endl;
|
std::cout << "I don't know anymore what to complain about" << std::endl;
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 15:38:32 by whaffman #+# #+# */
|
/* Created: 2025/03/23 15:38:32 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/23 15:44:11 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 12:29:34 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */
|
/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/24 14:29:54 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 12:20:49 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,14 +15,18 @@
|
|||||||
class Harl
|
class Harl
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string levels[4];
|
static std::string levels[4];
|
||||||
void (Harl::*levelFunc[4])();
|
static void (Harl::*levelFunc[4])();
|
||||||
void info();
|
void info();
|
||||||
void debug();
|
void debug();
|
||||||
void warning();
|
void warning();
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Harl();
|
Harl();
|
||||||
~Harl();
|
~Harl();
|
||||||
void complain(std::string level);
|
void complain(std::string level);
|
||||||
|
std::string getLevel(int i);
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -6,46 +6,45 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/23 15:09:28 by whaffman #+# #+# */
|
/* Created: 2025/03/23 15:09:28 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/23 15:44:03 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 12:26:34 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Harl.hpp"
|
#include "Harl.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string Harl::levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
|
||||||
|
void (Harl::*Harl::levelFunc[4])() = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
|
||||||
|
|
||||||
Harl::Harl()
|
Harl::Harl()
|
||||||
{
|
{
|
||||||
levels[0] = "DEBUG";
|
|
||||||
levels[1] = "INFO";
|
|
||||||
levels[2] = "WARNING";
|
|
||||||
levels[3] = "ERROR";
|
|
||||||
levelFunc[0] = &Harl::debug;
|
|
||||||
levelFunc[1] = &Harl::info;
|
|
||||||
levelFunc[2] = &Harl::warning;
|
|
||||||
levelFunc[3] = &Harl::error;
|
|
||||||
}
|
}
|
||||||
Harl::~Harl() {}
|
Harl::~Harl() {}
|
||||||
|
|
||||||
void Harl::debug()
|
void Harl::debug()
|
||||||
{
|
{
|
||||||
std::cout << "[DEBUG]" << std::endl;
|
std::cout << "[DEBUG]" << std::endl;
|
||||||
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!" << std::endl;
|
std::cout << "I put butter in the pan, to fry an egg." << std::endl;
|
||||||
}
|
}
|
||||||
void Harl::info()
|
void Harl::info()
|
||||||
{
|
{
|
||||||
std::cout << "[INFO]" << std::endl;
|
std::cout << "[INFO]" << std::endl;
|
||||||
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;
|
std::cout << "Tiny bubbles are appearing, the butter is Hot" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::warning()
|
void Harl::warning()
|
||||||
{
|
{
|
||||||
std::cout << "[WARNING]" << std::endl;
|
std::cout << "[WARNING]" << std::endl;
|
||||||
std::cout << "I think I deserve to have some extra bacon for free. I’ve been coming for years, whereas you started working here just last month." << std::endl;
|
std::cout << "The butter turns brown, It's really time to put in the eggs" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::error()
|
void Harl::error()
|
||||||
{
|
{
|
||||||
std::cout << "[ERROR]" << std::endl;
|
std::cout << "[ERROR]" << std::endl;
|
||||||
std::cout << "This is unacceptable! I want to speak to the manager now." << std::endl;
|
std::cout << "Too late, your house is on fire!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harl::complain(std::string level)
|
void Harl::complain(std::string level)
|
||||||
@ -60,3 +59,10 @@ void Harl::complain(std::string level)
|
|||||||
}
|
}
|
||||||
std::cout << "I don't know anymorre what to complain about" << std::endl;
|
std::cout << "I don't know anymorre what to complain about" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Harl::getLevel(int i)
|
||||||
|
{
|
||||||
|
if (i < 0 || i > 3)
|
||||||
|
return ("");
|
||||||
|
return (levels[i]);
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/03/24 14:30:26 by whaffman #+# #+# */
|
/* Created: 2025/03/24 14:30:26 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/24 14:40:35 by whaffman ######## odam.nl */
|
/* Updated: 2025/04/02 12:24:34 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
|
|
||||||
Harl harl;
|
Harl harl;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (argv[1] == levels[i])
|
if (argv[1] == harl.getLevel(i))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -34,17 +33,17 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 3:
|
|
||||||
harl.complain("ERROR");
|
|
||||||
case 2:
|
|
||||||
harl.complain("WARNING");
|
|
||||||
case 1:
|
|
||||||
harl.complain("INFO");
|
|
||||||
case 0:
|
case 0:
|
||||||
harl.complain("DEBUG");
|
harl.complain("DEBUG");
|
||||||
|
case 1:
|
||||||
|
harl.complain("INFO");
|
||||||
|
case 2:
|
||||||
|
harl.complain("WARNING");
|
||||||
|
case 3:
|
||||||
|
harl.complain("ERROR");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout << "[Probably complaining about insignificant problem]" << std::endl;
|
std::cout << "[Please only complain for real problems!]" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user