diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8497a3f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -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" - } -} \ No newline at end of file diff --git a/ex04/Replacer b/ex04/Replacer deleted file mode 100755 index afb8be5..0000000 Binary files a/ex04/Replacer and /dev/null differ diff --git a/ex04/Replacer.o b/ex04/Replacer.o deleted file mode 100644 index c2221b9..0000000 Binary files a/ex04/Replacer.o and /dev/null differ diff --git a/ex04/main.o b/ex04/main.o deleted file mode 100644 index c9507a0..0000000 Binary files a/ex04/main.o and /dev/null differ diff --git a/ex04/testfile b/ex04/testfile deleted file mode 100644 index 5762658..0000000 --- a/ex04/testfile +++ /dev/null @@ -1,2 +0,0 @@ -Dit is een test, maar niet zomaar een test -Dit is een test, maar niet zomaar een test diff --git a/ex04/testfile.replace b/ex04/testfile.replace deleted file mode 100644 index 402ddac..0000000 --- a/ex04/testfile.replace +++ /dev/null @@ -1,2 +0,0 @@ -Dit is een proef, maar niet zomaar een proef -Dit is een proef, maar niet zomaar een proef diff --git a/ex05/Harl b/ex05/Harl deleted file mode 100755 index 26648ab..0000000 Binary files a/ex05/Harl and /dev/null differ diff --git a/ex05/Harl.o b/ex05/Harl.o deleted file mode 100644 index 92bb6fa..0000000 Binary files a/ex05/Harl.o and /dev/null differ diff --git a/ex05/main.o b/ex05/main.o deleted file mode 100644 index ff164ee..0000000 Binary files a/ex05/main.o and /dev/null differ diff --git a/ex06/Makefile b/ex06/Makefile index 730a48b..cca308a 100644 --- a/ex06/Makefile +++ b/ex06/Makefile @@ -6,12 +6,12 @@ # 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 = -SRC = +NAME = harlFilter +SRC = main.cpp Harl.cpp -include ../common.mk diff --git a/ex06/inc/Harl.hpp b/ex06/inc/Harl.hpp new file mode 100644 index 0000000..a857e4b --- /dev/null +++ b/ex06/inc/Harl.hpp @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Harl.hpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/03/23 15:06:27 by whaffman #+# #+# */ +/* Updated: 2025/03/24 14:29:54 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include + +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); + }; \ No newline at end of file diff --git a/ex06/src/Harl.cpp b/ex06/src/Harl.cpp new file mode 100644 index 0000000..c40456b --- /dev/null +++ b/ex06/src/Harl.cpp @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* Harl.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* 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 didn’t put enough bacon in my burger! If you did, I wouldn’t 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. I’ve 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; +} \ No newline at end of file diff --git a/ex06/src/main.cpp b/ex06/src/main.cpp new file mode 100644 index 0000000..43ee75a --- /dev/null +++ b/ex06/src/main.cpp @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* main.cpp :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* 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); +} \ No newline at end of file