finished?

This commit is contained in:
whaffman 2025-03-28 16:05:41 +01:00
parent 1dc7d86a71
commit e857218775
13 changed files with 144 additions and 57 deletions

50
.vscode/settings.json vendored
View File

@ -1,50 +0,0 @@
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp",
"fstream": "cpp"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +0,0 @@
Dit is een test, maar niet zomaar een test
Dit is een test, maar niet zomaar een test

View File

@ -1,2 +0,0 @@
Dit is een proef, maar niet zomaar een proef
Dit is een proef, maar niet zomaar een proef

BIN
ex05/Harl

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,12 +6,12 @@
# By: whaffman <whaffman@student.codam.nl> +#+ # # By: whaffman <whaffman@student.codam.nl> +#+ #
# +#+ # # +#+ #
# Created: 2025/03/19 16:44:48 by whaffman #+# #+# # # Created: 2025/03/19 16:44:48 by whaffman #+# #+# #
# Updated: 2025/03/21 15:17:22 by whaffman ######## odam.nl # # Updated: 2025/03/24 14:28:03 by whaffman ######## odam.nl #
# # # #
# **************************************************************************** # # **************************************************************************** #
NAME = NAME = harlFilter
SRC = SRC = main.cpp Harl.cpp
-include ../common.mk -include ../common.mk

28
ex06/inc/Harl.hpp Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* Harl.hpp :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */
/* Updated: 2025/03/24 14:29:54 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include <iostream>
class Harl
{
private:
std::string levels[4];
void (Harl::*levelFunc[4])();
void info();
void debug();
void warning();
void error();
public:
Harl();
~Harl();
void complain(std::string level);
};

62
ex06/src/Harl.cpp Normal file
View File

@ -0,0 +1,62 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* Harl.cpp :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/03/23 15:09:28 by whaffman #+# #+# */
/* Updated: 2025/03/23 15:44:03 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
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() {}
void Harl::debug()
{
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;
}
void Harl::info()
{
std::cout << "[INFO]" << std::endl;
std::cout << "I cannot believe adding extra bacon costs more money. You didnt put enough bacon in my burger! If you did, I wouldnt be asking for more!" << std::endl;
}
void Harl::warning()
{
std::cout << "[WARNING]" << std::endl;
std::cout << "I think I deserve to have some extra bacon for free. Ive been coming for years, whereas you started working here just last month." << std::endl;
}
void Harl::error()
{
std::cout << "[ERROR]" << std::endl;
std::cout << "This is unacceptable! I want to speak to the manager now." << std::endl;
}
void Harl::complain(std::string level)
{
for (int i = 0; i < 4; i++)
{
if (level == levels[i])
{
(this->*levelFunc[i])();
return ;
}
}
std::cout << "I don't know anymorre what to complain about" << std::endl;
}

51
ex06/src/main.cpp Normal file
View File

@ -0,0 +1,51 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.cpp :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/03/24 14:30:26 by whaffman #+# #+# */
/* Updated: 2025/03/24 14:40:35 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
int main(int argc, char **argv)
{
const std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
Harl harl;
int i;
if (argc != 2)
{
std::cout << "Usage: ./harlFilter [DEBUG/INFO/WARNING/ERROR]" << std::endl;
return (1);
}
for (i = 0; i < 4; i++)
{
if (argv[1] == levels[i])
{
break;
}
}
switch (i)
{
case 3:
harl.complain("ERROR");
case 2:
harl.complain("WARNING");
case 1:
harl.complain("INFO");
case 0:
harl.complain("DEBUG");
break;
default:
std::cout << "[Probably complaining about insignificant problem]" << std::endl;
break;
}
return (0);
}