From b09dfcb7be50f75d0ecb60822076041026df88a9 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Sat, 12 Nov 2022 19:02:52 +0100 Subject: [PATCH] Major release --- .gitignore | 35 ++ .vscode/c_cpp_properties.json | 16 + .vscode/settings.json | 57 ++ CMakeLists.txt | 28 + config.hpp.in | 10 + external/CMakeLists.txt | 0 src/CMakeLists.txt | 24 + src/TopTeamBedrijfssimulaties/CMakeLists.txt | 8 + .../Starters/CMakeLists.txt | 10 + .../Starters/Starters.cpp | 539 ++++++++++++++++++ .../Starters/Starters.hpp | 115 ++++ .../TopTeamBedrijfssimulaties.hpp | 1 + src/cmdLineArgs.cpp | 71 +++ src/cmdLineArgs.hpp | 25 + src/debug.hpp | 21 + src/main.cpp | 14 + src/main.hpp | 11 + tests/CMakeLists.txt | 0 18 files changed, 985 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 CMakeLists.txt create mode 100644 config.hpp.in create mode 100644 external/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/TopTeamBedrijfssimulaties/CMakeLists.txt create mode 100644 src/TopTeamBedrijfssimulaties/Starters/CMakeLists.txt create mode 100644 src/TopTeamBedrijfssimulaties/Starters/Starters.cpp create mode 100644 src/TopTeamBedrijfssimulaties/Starters/Starters.hpp create mode 100644 src/TopTeamBedrijfssimulaties/TopTeamBedrijfssimulaties.hpp create mode 100644 src/cmdLineArgs.cpp create mode 100644 src/cmdLineArgs.hpp create mode 100644 src/debug.hpp create mode 100644 src/main.cpp create mode 100644 src/main.hpp create mode 100644 tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7667cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build folder +build/ \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..7959a28 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + ], + "defines": [], + "compilerPath": "/usr/lib64/ccache/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..51b1872 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,57 @@ +{ + "files.associations": { + "string": "cpp", + "algorithm": "cpp", + "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", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "random": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "slist": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1f16740 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(TopTeamBedrijfssimulatiesStarter LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set (VERSION_MAJOR 1) +set (VERSION_MINOR 0) + +include(GNUInstallDirs) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) + +# defines targets and sources +add_subdirectory(src) + +# contains an "external" library we will link to +add_subdirectory(external) + +# enable testing and define tests +enable_testing() +add_subdirectory(tests) diff --git a/config.hpp.in b/config.hpp.in new file mode 100644 index 0000000..94dedb2 --- /dev/null +++ b/config.hpp.in @@ -0,0 +1,10 @@ +#define VERSION_MAJOR @VERSION_MAJOR +#define VERSION_MINOR @VERSION_MINOR + +#define CONFIG_USE_IN_APP 1 +#define CONFIG_USE_FILE 2 +#define CONFIG_USE_MYSQL 3 + +#define storageType CONFIG_USE_MYSQL + +#define enableDebug 1 \ No newline at end of file diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b6cb96c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,24 @@ +add_executable(main main.cpp cmdLineArgs.cpp) + +# tell CMake to generate config.hpp +configure_file ( + "${PROJECT_SOURCE_DIR}/config.hpp.in" + "${PROJECT_BINARY_DIR}/config.hpp" + ) + +add_subdirectory(TopTeamBedrijfssimulaties) +#add_subdirectory(initial) +#add_subdirectory(io) +#add_subdirectory(parser) + +target_link_libraries(main + PRIVATE + TopTeamBedrijfssimulaties + ) + + target_include_directories(TopTeamBedrijfssimulaties + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/TopTeamBedrijfssimulaties + ${PROJECT_BINARY_DIR} + ) \ No newline at end of file diff --git a/src/TopTeamBedrijfssimulaties/CMakeLists.txt b/src/TopTeamBedrijfssimulaties/CMakeLists.txt new file mode 100644 index 0000000..0a57c06 --- /dev/null +++ b/src/TopTeamBedrijfssimulaties/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(TopTeamBedrijfssimulaties "") + +target_include_directories(TopTeamBedrijfssimulaties + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ) + +add_subdirectory(Starters) \ No newline at end of file diff --git a/src/TopTeamBedrijfssimulaties/Starters/CMakeLists.txt b/src/TopTeamBedrijfssimulaties/Starters/CMakeLists.txt new file mode 100644 index 0000000..62009bc --- /dev/null +++ b/src/TopTeamBedrijfssimulaties/Starters/CMakeLists.txt @@ -0,0 +1,10 @@ +target_sources(TopTeamBedrijfssimulaties + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Starters.cpp + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/Starters.cpp + ) +target_include_directories(TopTeamBedrijfssimulaties + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ) \ No newline at end of file diff --git a/src/TopTeamBedrijfssimulaties/Starters/Starters.cpp b/src/TopTeamBedrijfssimulaties/Starters/Starters.cpp new file mode 100644 index 0000000..e7ac327 --- /dev/null +++ b/src/TopTeamBedrijfssimulaties/Starters/Starters.cpp @@ -0,0 +1,539 @@ +#include "Starters.hpp" + +Starters_c::Starters_c(MachineStandaard standaard, unsigned int jaarproductieMachine1, + unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame) +: Starters_c(standaard, 1, jaarproductieMachine1, 0, 0, verkoopprijs, winstmargeWinkel, kwaliteit, reclame) +{ +} + +Starters_c::Starters_c(MachineStandaard standaard, unsigned int jaarproductieMachine1, + unsigned int jaarproductieMachine2, + unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame) +: Starters_c(standaard, 2, jaarproductieMachine1, jaarproductieMachine2, 0, verkoopprijs, winstmargeWinkel, kwaliteit, reclame) +{ + +} + +Starters_c::Starters_c(MachineStandaard standaard, unsigned int aantalMachines, unsigned int jaarproductieMachine1, + unsigned int jaarproductieMachine2, unsigned int jaarproductieMachine3, + unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame) +{ + if (checkInput(standaard, aantalMachines, jaarproductieMachine1, + jaarproductieMachine2, jaarproductieMachine3, verkoopprijs, + winstmargeWinkel, kwaliteit, reclame) == false) + { + throw "Starters_c::Starters_c Invalid input"; + } + this->standaard = standaard; + + this->A1 = aantalMachines; + this->A2 = jaarproductieMachine1; + this->A5 = jaarproductieMachine2; + this->A8 = jaarproductieMachine3; + + this->B1 = verkoopprijs; + this->B2 = winstmargeWinkel; + this->B3 = kwaliteit; + this->B4 = reclame; +} + +bool Starters_c::checkInput(MachineStandaard standaard, unsigned int aantalMachines, unsigned int jaarproductieMachine1, + unsigned int jaarproductieMachine2, unsigned int jaarproductieMachine3, + unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame) +{ + bool returnValue = true; + if (standaard == MachineStandaard::Standaard) + { + if (aantalMachines > Starters_c_aabtalMachines_max) + { + returnValue = false; + } + if (jaarproductieMachine1 > Starters_c_standaard_jaarProductie_max) + { + returnValue = false; + } + if (jaarproductieMachine2 > Starters_c_standaard_jaarProductie_max) + { + returnValue = false; + } + if (jaarproductieMachine3 > Starters_c_standaard_jaarProductie_max) + { + returnValue = false; + } + if (verkoopprijs < Starters_c_standaard_verkoopPrijs_min || verkoopprijs > Starters_c_standaard_verkoopPrijs_max) + { + returnValue = false; + } + if (winstmargeWinkel < Starters_c_standaard_winstMarge_min || winstmargeWinkel > Starters_c_standaard_winstMarge_max) + { + returnValue = false; + } + if (kwaliteit < Starters_c_standaard_kwaliteit_min || kwaliteit > Starters_c_standaard_kwaliteit_max) + { + returnValue = false; + } + if (reclame < Starters_c_standaard_reclame_min || reclame > Starters_c_standaard_reclame_max) + { + returnValue = false; + } + + return returnValue; + } + if (standaard == MachineStandaard::Luxe) + { + if (aantalMachines > Starters_c_aabtalMachines_max) + { + returnValue = false; + } + if (jaarproductieMachine1 > Starters_c_luxe_jaarProductie_max) + { + returnValue = false; + } + if (jaarproductieMachine2 > Starters_c_luxe_jaarProductie_max) + { + returnValue = false; + } + if (jaarproductieMachine3 > Starters_c_luxe_jaarProductie_max) + { + returnValue = false; + } + if (verkoopprijs < Starters_c_luxe_verkoopPrijs_min || verkoopprijs > Starters_c_luxe_verkoopPrijs_max) + { + returnValue = false; + } + if (winstmargeWinkel < Starters_c_luxe_winstMarge_min || winstmargeWinkel > Starters_c_luxe_winstMarge_max) + { + returnValue = false; + } + if (kwaliteit < Starters_c_luxe_kwaliteit_min || kwaliteit > Starters_c_luxe_kwaliteit_max) + { + returnValue = false; + } + if (reclame < Starters_c_luxe_reclame_min || reclame > Starters_c_luxe_reclame_max) + { + returnValue = false; + } + + return returnValue; + } + + debugErrorln("Starters_c::checkInput() - Invalid input"); + return 0; +} + +float Starters_c::calculate() +{ + // A productie + // Machine 1 + this->A3 = ProductieKosten(this->standaard, this->A2); + this->A4 = this->A2 * this->A3; + // Machine 2 + this->A6 = ProductieKosten(this->standaard, this->A5); + this->A7 = this->A5 * this->A6; + // Machine 3 + this->A9 = ProductieKosten(this->standaard, this->A8); + this->A10 = this->A8 * this->A9; + // Totale productiekosten + this->A11 = this->A4 + this->A7 + this->A10; + this->A12 = this->A2 + this->A5 + this->A8; + this->A13 = static_cast(this->A11) / static_cast(this->A12); + + // B marketing + // ingevuld door constructor + + // C Bestellingen + this->C1 = 2000; + this->C2 = ExtraBestellingenVerkoopPrijs(this->standaard, this->B1); + this->C3 = ExtraBestellingenWinstmarge(this->standaard, this->B2); + this->C4 = ExtraBestellingenKwaliteit(this->standaard, this->B3); + this->C5 = ExtraBestellingenReclame(this->standaard, this->B4); + this->C6 = this->C1 + this->C2 + this->C3 + this->C4 + this->C5; + if (this->C6 < this->A12) + this->C7 = this->C6; + else + this->C7 = this->A12; + + // D Resultaatberekeningen + this->D1 = this->C7; + this->D2 = this->B1; + this->D3 = this->D1 * this->D2; + this->D4 = this->D1 * this->A13; + this->D5 = this->D3 * this->B2 / 100; + this->D6 = this->D3 - this->D4 - this->D5; + this->D7 = this->B3; + this->D8 = this->B4; + if (standaard == MachineStandaard::Standaard) + this->D9 = this->A12 - this->C7; + else + this->D9 = 2 * (this->A12 - this->C7); + this->D10 = this->D6 - this->D7 - this->D8 - this->D9; + + return this->D10; + + debugErrorln("Starters_c::calculate() - Invalid input"); + return -1; +} + +float Starters_c::ProductiKostenLuxe(unsigned int productieAantal) +{ + if (productieAantal == 0) + return 0; + if (productieAantal <= 600) + return 31.50; + if (productieAantal <= 650) + return 31.30; + if (productieAantal <= 700) + return 30.80; + if (productieAantal <= 750) + return 29.80; + if (productieAantal <= 800) + return 28.10; + if (productieAantal <= 850) + return 26.50; + if (productieAantal <= 900) + return 25.20; + if (productieAantal <= 950) + return 24.40; + if (productieAantal <= 1000) + return 24.00; + if (productieAantal <= 1050) + return 24.40; + if (productieAantal <= 1100) + return 25.20; + if (productieAantal <= 1150) + return 26.50; + if (productieAantal <= 1200) + return 28.10; + if (productieAantal <= 1250) + return 29.80; + if (productieAantal <= 1300) + return 30.80; + if (productieAantal <= 1350) + return 31.30; + if (productieAantal >= 1400 && productieAantal <= 2000) + return 31.50; + + debugErrorln("ProductiKostenStandaard: productieAantal " + std::to_string(productieAantal) + " niet in range"); + return -1; +} + +float Starters_c::ProductiKostenStandaard(unsigned int productieAantal) +{ + if (productieAantal == 0) + return 0; + if (productieAantal <= 1200) + return 27.50; + if (productieAantal <= 1300) + return 27.30; + if (productieAantal <= 1400) + return 26.80; + if (productieAantal <= 1500) + return 25.80; + if (productieAantal <= 1600) + return 24.10; + if (productieAantal <= 1700) + return 22.50; + if (productieAantal <= 1800) + return 21.20; + if (productieAantal <= 1900) + return 20.40; + if (productieAantal <= 2000) + return 20.00; + if (productieAantal <= 2100) + return 20.40; + if (productieAantal <= 2200) + return 21.20; + if (productieAantal <= 2300) + return 22.50; + if (productieAantal <= 2400) + return 24.10; + if (productieAantal <= 2500) + return 25.80; + if (productieAantal <= 2600) + return 26.80; + if (productieAantal <= 2700) + return 27.30; + if (productieAantal >= 28000 && productieAantal <= 4000) + return 27.50; + + debugErrorln("ProductiKostenLuxe: productieAantal " + std::to_string(productieAantal) + " is niet in range"); + return -1; +} + +float Starters_c::ProductieKosten(Starters_c::MachineStandaard standaard, unsigned int productieAantal) +{ + switch (standaard) + { + case MachineStandaard::Standaard: + return ProductiKostenStandaard(productieAantal); + break; + case MachineStandaard::Luxe: + return ProductiKostenLuxe(productieAantal); + break; + default: + return -1; + break; + } +} + +int Starters_c::ExtraBestellingenVerkoopPrijsStandaard(unsigned int verkoopprijs) +{ + if (verkoopprijs == 34) + return 600; + if (verkoopprijs == 35) + return 540; + if (verkoopprijs == 36) + return 480; + if (verkoopprijs == 37) + return 420; + if (verkoopprijs == 38) + return 360; + if (verkoopprijs == 39) + return 300; + if (verkoopprijs == 40) + return 240; + if (verkoopprijs == 41) + return 180; + if (verkoopprijs == 42) + return 120; + if (verkoopprijs == 43) + return 60; + if (verkoopprijs == 44) + return 0; + + debugErrorln("ExtraBestellingenVerkoopPrijsStandaard: verkoopprijs " + std::to_string(verkoopprijs) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenVerkoopPrijsLuxe(unsigned int verkoopprijs) +{ + if (verkoopprijs == 95) + return 10; + if (verkoopprijs == 96) + return 9; + if (verkoopprijs == 97) + return 8; + if (verkoopprijs == 98) + return 7; + if (verkoopprijs == 99) + return 6; + if (verkoopprijs == 100) + return 5; + if (verkoopprijs == 101) + return 4; + if (verkoopprijs == 102) + return 3; + if (verkoopprijs == 103) + return 2; + if (verkoopprijs == 104) + return 1; + if (verkoopprijs == 105) + return 0; + + debugErrorln("ExtraBestellingenVerkoopPrijsLuxe: verkoopprijs " + std::to_string(verkoopprijs) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenVerkoopPrijs(Starters_c::MachineStandaard standaard, unsigned int verkoopprijs) +{ + switch (standaard) + { + case MachineStandaard::Standaard: + return ExtraBestellingenVerkoopPrijsStandaard(verkoopprijs); + break; + case MachineStandaard::Luxe: + return ExtraBestellingenVerkoopPrijsLuxe(verkoopprijs); + break; + default: + return -1; + break; + } +} + +int Starters_c::ExtraBestellingenWinstmargeStandaard(unsigned int winstmarge) +{ + if (winstmarge == 15) + return 30; + if (winstmarge == 20) + return 40; + if (winstmarge == 25) + return 50; + if (winstmarge == 30) + return 60; + if (winstmarge == 35) + return 70; + if (winstmarge == 40) + return 80; + if (winstmarge == 45) + return 90; + if (winstmarge == 50) + return 100; + + if (winstmarge >= 15 && winstmarge <= 50) + return winstmarge * 100 / 50; + + debugErrorln("ExtraBestellingenWinstmargeLuxe: winstmarge " + std::to_string(winstmarge) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenWinstmargeLuxe(unsigned int winstmarge) +{ + if (winstmarge == 25) + return 375; + if (winstmarge == 30) + return 450; + if (winstmarge == 35) + return 525; + if (winstmarge == 40) + return 600; + if (winstmarge == 45) + return 675; + if (winstmarge == 50) + return 750; + + if (winstmarge >= 25 && winstmarge <= 50) + return winstmarge * 750 / 50; + + debugErrorln("ExtraBestellingenWinstmargeLuxe: winstmarge " + std::to_string(winstmarge) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenWinstmarge(MachineStandaard standaard, unsigned int winstmarge) +{ + switch (standaard) + { + case MachineStandaard::Standaard: + return ExtraBestellingenWinstmargeStandaard(winstmarge); + break; + case MachineStandaard::Luxe: + return ExtraBestellingenWinstmargeLuxe(winstmarge); + break; + default: + return -1; + break; + } +} + +int Starters_c::ExtraBestellingenKwaliteitStandaard(unsigned int budgetKwaliteit) +{ + if (budgetKwaliteit == 3000) + return 75; + if (budgetKwaliteit == 4000) + return 100; + if (budgetKwaliteit == 5000) + return 125; + if (budgetKwaliteit == 6000) + return 150; + if (budgetKwaliteit == 7000) + return 175; + if (budgetKwaliteit == 8000) + return 200; + if (budgetKwaliteit == 9000) + return 225; + if (budgetKwaliteit == 10000) + return 250; + + if (budgetKwaliteit >= 3000 && budgetKwaliteit <= 10000) + return budgetKwaliteit * 250 / 10000; + + debugErrorln("ExtraBestellingenKwaliteitStandaard: budgetKwaliteit " + std::to_string(budgetKwaliteit) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenKwaliteitLuxe(unsigned int budgetKwaliteit) +{ + if (budgetKwaliteit == 50000) + return 500; + if (budgetKwaliteit == 60000) + return 600; + if (budgetKwaliteit == 70000) + return 700; + if (budgetKwaliteit == 80000) + return 800; + if (budgetKwaliteit == 90000) + return 900; + if (budgetKwaliteit == 100000) + return 1000; + + if (budgetKwaliteit >= 5000 && budgetKwaliteit <= 100000) + return budgetKwaliteit * 1000 / 100000; + + debugErrorln("ExtraBestellingenKwaliteitLuxe: budgetKwaliteit " + std::to_string(budgetKwaliteit) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenKwaliteit(MachineStandaard standaard, unsigned int budgetKwaliteit) +{ + switch (standaard) + { + case MachineStandaard::Standaard: + return ExtraBestellingenKwaliteitStandaard(budgetKwaliteit); + break; + case MachineStandaard::Luxe: + return ExtraBestellingenKwaliteitLuxe(budgetKwaliteit); + break; + default: + return -1; + break; + } +} + +int Starters_c::ExtraBestellingenReclameStandaard(unsigned int budgetReclame) +{ + if (budgetReclame == 25000) + return 1500; + if (budgetReclame == 30000) + return 1800; + if (budgetReclame == 35000) + return 2100; + if (budgetReclame == 40000) + return 2400; + if (budgetReclame == 45000) + return 2700; + if (budgetReclame == 50000) + return 3000; + + if (budgetReclame >= 25000 && budgetReclame <= 50000) + return budgetReclame * 3000 / 50000; + + debugErrorln("ExtraBestellingenReclameStandaard: budgetReclame " + std::to_string(budgetReclame) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenReclameLuxe(unsigned int budgetReclame) +{ + if (budgetReclame == 25000) + return 375; + if (budgetReclame == 30000) + return 450; + if (budgetReclame == 35000) + return 525; + if (budgetReclame == 40000) + return 600; + if (budgetReclame == 45000) + return 675; + if (budgetReclame == 50000) + return 750; + + if (budgetReclame >= 25000 && budgetReclame <= 50000) + return budgetReclame * 750 / 50000; + + debugErrorln("ExtraBestellingenReclameLuxe: budgetReclame " + std::to_string(budgetReclame) + " is niet in range"); + return -1; +} + +int Starters_c::ExtraBestellingenReclame(MachineStandaard standaard, unsigned int budgetReclame) +{ + switch (standaard) + { + case MachineStandaard::Standaard: + return ExtraBestellingenReclameStandaard(budgetReclame); + break; + case MachineStandaard::Luxe: + return ExtraBestellingenReclameLuxe(budgetReclame); + break; + default: + return -1; + break; + } +} \ No newline at end of file diff --git a/src/TopTeamBedrijfssimulaties/Starters/Starters.hpp b/src/TopTeamBedrijfssimulaties/Starters/Starters.hpp new file mode 100644 index 0000000..f94a778 --- /dev/null +++ b/src/TopTeamBedrijfssimulaties/Starters/Starters.hpp @@ -0,0 +1,115 @@ +#include +#include +#include +#include + +#include "debug.hpp" + +#define Starters_c_aabtalMachines_max 3 + +#define Starters_c_standaard_jaarProductie_max 4000 +#define Starters_c_standaard_verkoopPrijs_min 34 +#define Starters_c_standaard_verkoopPrijs_max 44 +#define Starters_c_standaard_winstMarge_min 15 +#define Starters_c_standaard_winstMarge_max 50 +#define Starters_c_standaard_kwaliteit_min 3000 +#define Starters_c_standaard_kwaliteit_max 10000 +#define Starters_c_standaard_reclame_min 25000 +#define Starters_c_standaard_reclame_max 50000 + +#define Starters_c_luxe_jaarProductie_max 2000 +#define Starters_c_luxe_verkoopPrijs_min 95 +#define Starters_c_luxe_verkoopPrijs_max 105 +#define Starters_c_luxe_winstMarge_min 25 +#define Starters_c_luxe_winstMarge_max 50 +#define Starters_c_luxe_kwaliteit_min 5000 +#define Starters_c_luxe_kwaliteit_max 10000 +#define Starters_c_luxe_reclame_min 25000 +#define Starters_c_luxe_reclame_max 50000 + +class Starters_c +{ +public: +enum class MachineStandaard {Standaard, Luxe}; +Starters_c(MachineStandaard standaard, unsigned int jaarproductieMachine1, +unsigned int jaarproductieMachine2, +unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame); +Starters_c(MachineStandaard standaard, unsigned int jaarproductieMachine1, +unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame); +Starters_c(MachineStandaard standaard, unsigned int aantalMachines, unsigned int jaarproductieMachine1, +unsigned int jaarproductieMachine2, unsigned int jaarproductieMachine3, +unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame); + +bool checkInput(MachineStandaard standaard, unsigned int aantalMachines, unsigned int jaarproductieMachine1, +unsigned int jaarproductieMachine2, unsigned int jaarproductieMachine3, +unsigned int verkoopprijs, unsigned int winstmargeWinkel, unsigned int kwaliteit, unsigned int reclame); + +float calculate(); + +private: +protected: +float ProductiKostenStandaard(unsigned int productieAantal); +float ProductiKostenLuxe(unsigned int productieAantal); +float ProductieKosten(MachineStandaard standaard, unsigned int productieAantal); + +int ExtraBestellingenVerkoopPrijsStandaard(unsigned int verkoopprijs); +int ExtraBestellingenVerkoopPrijsLuxe(unsigned int verkoopprijs); +int ExtraBestellingenVerkoopPrijs(MachineStandaard standaard, unsigned int verkoopprijs); + +int ExtraBestellingenWinstmargeStandaard(unsigned int winstmarge); +int ExtraBestellingenWinstmargeLuxe(unsigned int winstmarge); +int ExtraBestellingenWinstmarge(MachineStandaard standaard, unsigned int winstmarge); + +int ExtraBestellingenKwaliteitStandaard(unsigned int budgetKwaliteit); +int ExtraBestellingenKwaliteitLuxe(unsigned int budgetKwaliteit); +int ExtraBestellingenKwaliteit(MachineStandaard standaard, unsigned int budgetKwaliteit); + +int ExtraBestellingenReclameStandaard(unsigned int budgetReclame); +int ExtraBestellingenReclameLuxe(unsigned int budgetReclame); +int ExtraBestellingenReclame(MachineStandaard standaard, unsigned int budgetReclame); + +void calculateProductie(void); +void calculateMarketing(void); +void calculateBestellingen(void); +void calculateResulaat(void); + +MachineStandaard standaard; + +int A1 = 0; +int A2 = 0; +int A3 = 0; +int A4 = 0; +int A5 = 0; +int A6 = 0; +int A7 = 0; +int A8 = 0; +int A9 = 0; +int A10 = 0; +int A11 = 0; +int A12 = 0; +float A13 = 0; + +int B1 = 0; +int B2 = 0; +int B3 = 0; +int B4 = 0; + +int C1 = 200; +int C2 = 0; +int C3 = 0; +int C4 = 0; +int C5 = 0; +int C6 = 0; +int C7 = 0; + +int D1 = 0; +int D2 = 0; +int D3 = 0; +int D4 = 0; +int D5 = 0; +int D6 = 0; +int D7 = 0; +int D8 = 0; +int D9 = 0; +int D10 = 0; +}; \ No newline at end of file diff --git a/src/TopTeamBedrijfssimulaties/TopTeamBedrijfssimulaties.hpp b/src/TopTeamBedrijfssimulaties/TopTeamBedrijfssimulaties.hpp new file mode 100644 index 0000000..02512eb --- /dev/null +++ b/src/TopTeamBedrijfssimulaties/TopTeamBedrijfssimulaties.hpp @@ -0,0 +1 @@ +#include "Starters.hpp" \ No newline at end of file diff --git a/src/cmdLineArgs.cpp b/src/cmdLineArgs.cpp new file mode 100644 index 0000000..26344d0 --- /dev/null +++ b/src/cmdLineArgs.cpp @@ -0,0 +1,71 @@ +#include "cmdLineArgs.hpp" + +cmdLineArgs_c::cmdLineArgs_c(int argc, char *argv[]) +{ + for (int i = 0; i < argc; i++) + { + this->args.push_back(argv[i]); + } + +} + +std::string cmdLineArgs_c::get_option( + const std::string &option_name) +{ + for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it) + { + if (*it == option_name) + if (it + 1 != end) + return *(it + 1); + } + + return ""; +} + +bool cmdLineArgs_c::has_option( + const std::string &option_name) +{ + for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it) + { + if (*it == option_name) + return true; + } + + return false; +} + +void cmdLineArgs_c::setUsage(std::string usage) +{ + this->usage = usage; +} +std::string cmdLineArgs_c::getUsage() +{ + return this->usage; +} + +bool cmdLineArgs_c::available( + const std::string &option_name, + const std::string usage +) +{ + for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it) + { + if (*it == option_name) + return true; + } + debugWarnln("Missing option: " << option_name << " " << usage); + return false; +} + +bool cmdLineArgs_c::available( + const std::string &option_name +) +{ + for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it) + { + if (*it == option_name) + return true; + } + debugWarnln("Missing option: " << option_name << std::endl << "\t" << this->usage); + return false; +} \ No newline at end of file diff --git a/src/cmdLineArgs.hpp b/src/cmdLineArgs.hpp new file mode 100644 index 0000000..238de01 --- /dev/null +++ b/src/cmdLineArgs.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include "debug.hpp" + +class cmdLineArgs_c +{ +public: + cmdLineArgs_c(int argc, char *argv[]); + std::string get_option( + const std::string &option_name); + bool has_option( + const std::string &option_name); + void setUsage(std::string usage); + std::string getUsage(); + bool available( + const std::string &option_name, const std::string usage); + bool available( + const std::string &option_name); + +private: + std::vector args; + std::string usage; +}; \ No newline at end of file diff --git a/src/debug.hpp b/src/debug.hpp new file mode 100644 index 0000000..7f9b235 --- /dev/null +++ b/src/debug.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include + +#include "config.hpp" + +#if enableDebug == 1 +#define debugln(x) std::cout << "\033[32m" << x << std::endl << "\033[0m"; +#define debug(x) std::cout << "\033[32m" << x << "\033[0m"; +#define debugWarn(x) std::cerr << "\033[33m" << x << "\033[0m"; +#define debugWarnln(x) std::cerr << "\033[33m" << x << std::endl << "\033[0m"; +#define debugErrorln(x) std::cerr << "\033[31m" << x << std::endl << "\033[0m"; +#define debugError(x) std::cerr "\033[31m" << x << "\033[0m"; +#else +#define debugln(x) +#define debug(x) +#define debugWarn(x) +#define debugWarnln(x) +#define debugErrorln(x) +#define debugError(x) +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..d6ea007 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,14 @@ +#include "main.hpp" + +int main(int argc, char *argv[]) +{ + cmdLineArgs_c cmdline(argc, argv); + + Starters_c spelronde1(Starters_c::MachineStandaard::Standaard, 3, 2000, 2000, 2000, 40, 40, 6000, 45000); + Starters_c spelronde2(Starters_c::MachineStandaard::Luxe, 1000, 1000, 105, 25, 9000, 25000); + + std::cout << "Spelronde 1: " << spelronde1.calculate() << std::endl; + std::cout << "Spelronde 2: " << spelronde2.calculate() << std::endl; + + return 0; +} \ No newline at end of file diff --git a/src/main.hpp b/src/main.hpp new file mode 100644 index 0000000..fd197b2 --- /dev/null +++ b/src/main.hpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "config.hpp" +#include "cmdLineArgs.hpp" +#include "TopTeamBedrijfssimulaties.hpp" \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..e69de29