commit da285f1570fa7fc077c0de9ec0b2918859265eaa Author: lucaspalomodevelop Date: Sat Aug 5 16:16:40 2023 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40a37af --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.out +mate +.ccls-cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..45b1785 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 lucaspalomodevelop + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..457850a --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +all: + g++ -v mate.cpp mate.hpp -o mate +clean: + rm -v mate +install: + sudo cp -v mate /usr/bin/mate +uninstall: + sudo rm -v /usr/bin/mate diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d0c010 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Mate-Rechner +Berechnung des idealen Mate Konsums + +## Benutzen + +* compile: `make` +* clean: `make clean` +* run: `./mate` +* install: `make install` \ No newline at end of file diff --git a/coffee.cpp b/coffee.cpp new file mode 100644 index 0000000..45bc159 --- /dev/null +++ b/coffee.cpp @@ -0,0 +1,137 @@ +#include +#include +#include +using namespace std; + +enum KaffeeSorte +{ + Arabica = 1, + Robusta = 2, + Espresso = 3, + Americano = 4, + Cappuccino = 5, + Latte = 6, + Mocha = 7, +}; + +std::tuple get_markenname_und_koffeingehalt(KaffeeSorte sorte) +{ + int Koffeingehalt; + string markenname; + int sorte_id; + + cout << "Folgende Kaffeesorten stehen zur Verfügung:\n"; + cout << "[1] Arabica\n[2] Robusta\n[3] Espresso\n[4] Americano\n[5] Cappuccino\n[6] Latte\n[7] Mocha\ninput: "; + cin >> sorte_id; + + switch (sorte) + { + case Arabica: + Koffeingehalt = 80; + markenname = "Arabica"; + break; + case Robusta: + Koffeingehalt = 100; + markenname = "Robusta"; + break; + case Espresso: + Koffeingehalt = 70; + markenname = "Espresso"; + break; + case Americano: + Koffeingehalt = 60; + markenname = "Americano"; + break; + case Cappuccino: + Koffeingehalt = 40; + markenname = "Cappuccino"; + break; + case Latte: + Koffeingehalt = 30; + markenname = "Latte"; + break; + case Mocha: + Koffeingehalt = 50; + markenname = "Mocha"; + break; + default: + break; + } + + return std::make_tuple(markenname, Koffeingehalt); +} + +int coffeeMain() +{ + int kaffee, Koffeingehalt, sorte, kmenge, ergebnis; + string input; + string markenname; + + cout << " ( ) ( ) )\n"; + cout << " ) ( ) ( (\n"; + cout << " ( ) ( ) )\n"; + cout << "\n"; + cout << " _____________\n"; + cout << " <_____________> ___\n"; + cout << " | |/ _ \\n"; + cout << " | | | |\n"; + cout << " | |_| |\n"; + cout << " ___| |\\___/\n"; + cout << "/ \\___________/ \\n"; + cout << "\\_____________________/\n"; + + cout << "Dieser Rechner weiß wie viel Kaffee du am Tag brauchst!\nkennst du die Anzahl? J/N\ninput:"; + cin >> input; + if (input == "J" || input == "j") + { + system("clear"); + cout << "****************************************************************\n" + << "* [i] Bitte gib die Anzahl der Tassen Kaffee an, die du brauchst *\n" + << "****************************************************************\n\n" + << "input: "; + cin >> kaffee; + if (kaffee < 2) + { + cout << "Für einen erfolgreichen Tag benötigst du mehr als 1 Tasse Kaffee"; + return 0; + } + + std::tuple marke = get_markenname_und_koffeingehalt(KaffeeSorte::Espresso); + + Koffeingehalt = std::get<1>(marke); + markenname = std::get<0>(marke); + + cout << "du brauchst " << kaffee << " Tassen Kaffee!!!\n" + << "der Koffeingehalt für deine " << kaffee << " Tassen liegt bei " << Koffeingehalt << " mg.\n\n" + << "Ein Hyperbel sagte: du brauchst immer eine Tasse Kaffee mehr als du hast\n\n" + << "--------------------------------[Hinweis]--------------------------------\n" + << "Bitte Beachte: Erhöhter Koffeingehalt. Für Kinder und schwangere oder stillende Frauen nicht empfohlen\n\n"; + } + else if (input == "N" || input == "n") + { + system("clear"); + cout << "Bitte gebe an, wie viel Koffein du heute zu dir nehmen willst (in mg).\ninput: "; + cin >> kmenge; + std::tuple marke = get_markenname_und_koffeingehalt(KaffeeSorte::Espresso); + + markenname = std::get<0>(marke); + Koffeingehalt = std::get<1>(marke); + + ergebnis = kmenge / Koffeingehalt; + cout << "Für deinen Tag benötigst du " << ergebnis << " Tassen " << markenname; + cout << "\n"; + cout << "--------------------------------[Hinweis]--------------------------------\n"; + cout << "Bitte Beachte: Erhöhter Koffeingehalt. Für Kinder und schwangere oder stillende Frauen nicht empfohlen\n"; + cout << "\n"; + } + else + cout << "Error"; + + return 0; +} + +// int main() +// { +// coffeeMain(); +// return 0; +// } diff --git a/coffee.hpp b/coffee.hpp new file mode 100644 index 0000000..ad9efbe --- /dev/null +++ b/coffee.hpp @@ -0,0 +1,7 @@ +#ifndef MATE_H +#define MATE_H + +#include +extern int kaffee, Koffeingehalt, marke, kmenge, ergebnis; +extern std::string input, markenname; +#endif \ No newline at end of file diff --git a/initModule.hpp b/initModule.hpp new file mode 100644 index 0000000..fbfb92d --- /dev/null +++ b/initModule.hpp @@ -0,0 +1,15 @@ +#include "./coffee.cpp" +#include "../../module.hpp" + +#include +#include +#include + +class KaffeeRechner : public Module +{ +public: + KaffeeRechner() : Module("Coffee-Rechner", "Rechnet den Koffeingehalt von Kaffee aus") + { + this->setInit(coffeeMain); + } +}; \ No newline at end of file