Files
TopTeamBedrijfssimulaties-S…/src/TopTeamBedrijfssimulaties/Starters/Starters.cpp
2022-11-13 00:38:01 +01:00

674 lines
20 KiB
C++

#include "Starters.hpp"
Starters_c::Starters_c(MachineStandard Standard, unsigned int annualProductionMachine1,
unsigned int salesPrice, unsigned int profitMarginShop, unsigned int quality, unsigned int advertisement)
: Starters_c(Standard, 1, annualProductionMachine1, 0, 0, salesPrice, profitMarginShop, quality, advertisement)
{
}
Starters_c::Starters_c(MachineStandard Standard, unsigned int annualProductionMachine1,
unsigned int annualProductionMachine2,
unsigned int salesPrice, unsigned int profitMarginShop, unsigned int quality, unsigned int advertisement)
: Starters_c(Standard, 2, annualProductionMachine1, annualProductionMachine2, 0, salesPrice, profitMarginShop, quality, advertisement)
{
}
Starters_c::Starters_c(MachineStandard Standard, unsigned int annualProductionMachine1,
unsigned int annualProductionMachine2, unsigned int annualProductionMachine3,
unsigned int salesPrice, unsigned int profitMarginShop, unsigned int quality, unsigned int advertisement)
: Starters_c(Standard, 3, annualProductionMachine1, annualProductionMachine2, annualProductionMachine3, salesPrice, profitMarginShop, quality, advertisement)
{
}
Starters_c::Starters_c(MachineStandard Standard, unsigned int NMachines, unsigned int annualProductionMachine1,
unsigned int annualProductionMachine2, unsigned int annualProductionMachine3,
unsigned int salesPrice, unsigned int profitMarginShop, unsigned int quality, unsigned int advertisement)
{
if (checkInput(Standard, NMachines, annualProductionMachine1,
annualProductionMachine2, annualProductionMachine3, salesPrice,
profitMarginShop, quality, advertisement) == false)
{
throw "Starters_c::Starters_c Invalid input";
}
this->Standard = Standard;
this->A1 = NMachines;
this->A2 = annualProductionMachine1;
this->A5 = annualProductionMachine2;
this->A8 = annualProductionMachine3;
this->B1 = salesPrice;
this->B2 = profitMarginShop;
this->B3 = quality;
this->B4 = advertisement;
}
bool Starters_c::checkInput(MachineStandard Standard, unsigned int NMachines, unsigned int annualProductionMachine1,
unsigned int annualProductionMachine2, unsigned int annualProductionMachine3,
unsigned int salesPrice, unsigned int profitMarginShop, unsigned int quality, unsigned int advertisement)
{
bool returnValue = true;
if (Standard == MachineStandard::Standard)
{
if (NMachines > Starters_c_aabtalMachines_max)
{
returnValue = false;
}
if (annualProductionMachine1 > Starters_c_Standard_yearProduction_max)
{
returnValue = false;
}
if (annualProductionMachine2 > Starters_c_Standard_yearProduction_max)
{
returnValue = false;
}
if (annualProductionMachine3 > Starters_c_Standard_yearProduction_max)
{
returnValue = false;
}
if (salesPrice < Starters_c_Standard_salesPrice_min || salesPrice > Starters_c_Standard_salesPrice_max)
{
returnValue = false;
}
if (profitMarginShop < Starters_c_Standard_profitMargin_min || profitMarginShop > Starters_c_Standard_profitMargin_max)
{
returnValue = false;
}
if (quality < Starters_c_Standard_quality_min || quality > Starters_c_Standard_quality_max)
{
returnValue = false;
}
if (advertisement < Starters_c_Standard_advertisement_min || advertisement > Starters_c_Standard_advertisement_max)
{
returnValue = false;
}
return returnValue;
}
if (Standard == MachineStandard::Luxe)
{
if (NMachines > Starters_c_aabtalMachines_max)
{
returnValue = false;
}
if (annualProductionMachine1 > Starters_c_luxe_yearProduction_max)
{
returnValue = false;
}
if (annualProductionMachine2 > Starters_c_luxe_yearProduction_max)
{
returnValue = false;
}
if (annualProductionMachine3 > Starters_c_luxe_yearProduction_max)
{
returnValue = false;
}
if (salesPrice < Starters_c_luxe_salesPrice_min || salesPrice > Starters_c_luxe_salesPrice_max)
{
returnValue = false;
}
if (profitMarginShop < Starters_c_luxe_profitMargin_min || profitMarginShop > Starters_c_luxe_profitMargin_max)
{
returnValue = false;
}
if (quality < Starters_c_luxe_quality_min || quality > Starters_c_luxe_quality_max)
{
returnValue = false;
}
if (advertisement < Starters_c_luxe_advertisement_min || advertisement > Starters_c_luxe_advertisement_max)
{
returnValue = false;
}
return returnValue;
}
debugErrorln("Starters_c::checkInput() - Invalid input");
return 0;
}
void Starters_c::setStandard(MachineStandard Standard)
{
this->Standard = Standard;
}
void Starters_c::setNMachines(unsigned int NMachines)
{
if (checkInput(Standard, NMachines, A2, A5, A8, B1, B2, B3, B4) == false)
{
throw "Starters_c::setNMachines Invalid input";
}
this->A1 = NMachines;
}
void Starters_c::setAnualProductionMachine1(unsigned int annualProductionMachine1)
{
if (checkInput(Standard, A1, annualProductionMachine1, A5, A8, B1, B2, B3, B4) == false)
{
throw "Starters_c::setAnualProductionMachine1 Invalid input";
}
this->A2 = annualProductionMachine1;
}
void Starters_c::setAnualProductionMachine2(unsigned int annualProductionMachine2)
{
if (checkInput(Standard, A1, A2, annualProductionMachine2, A8, B1, B2, B3, B4) == false)
{
throw "Starters_c::setAnualProductionMachine2 Invalid input";
}
this->A5 = annualProductionMachine2;
}
void Starters_c::setAnualProductionMachine3(unsigned int annualProductionMachine3)
{
if (checkInput(Standard, A1, A2, A5, annualProductionMachine3, B1, B2, B3, B4) == false)
{
throw "Starters_c::setAnualProductionMachine3 Invalid input";
}
this->A8 = annualProductionMachine3;
}
void Starters_c::setSalesPrice(unsigned int salesPrice)
{
if (checkInput(Standard, A1, A2, A5, A8, salesPrice, B2, B3, B4) == false)
{
throw "Starters_c::setSalesPrice Invalid input";
}
this->B1 = salesPrice;
}
void Starters_c::setProfitMarginShop(unsigned int profitMarginShop)
{
if (checkInput(Standard, A1, A2, A5, A8, B1, profitMarginShop, B3, B4) == false)
{
throw "Starters_c::setProfitMarginShop Invalid input";
}
this->B2 = profitMarginShop;
}
void Starters_c::setQuality(unsigned int quality)
{
if (checkInput(Standard, A1, A2, A5, A8, B1, B2, quality, B4) == false)
{
throw "Starters_c::setQuality Invalid input";
}
this->B3 = quality;
}
void Starters_c::setAdvertisement(unsigned int advertisement)
{
if (checkInput(Standard, A1, A2, A5, A8, B1, B2, B3, advertisement) == false)
{
throw "Starters_c::setAdvertisement Invalid input";
}
this->B4 = advertisement;
}
Starters_c::MachineStandard Starters_c::getStandard(void) const
{
return Standard;
}
unsigned int Starters_c::getNMachines(void) const
{
return A1;
}
unsigned int Starters_c::getAnualProductionMachine1(void) const
{
return A2;
}
unsigned int Starters_c::getAnualProductionMachine2(void) const
{
return A5;
}
unsigned int Starters_c::getAnualProductionMachine3(void) const
{
return A8;
}
unsigned int Starters_c::getSalesPrice(void) const
{
return B1;
}
unsigned int Starters_c::getProfitMarginShop(void) const
{
return B2;
}
unsigned int Starters_c::getQuality(void) const
{
return B3;
}
unsigned int Starters_c::getAdvertisement(void) const
{
return B4;
}
float Starters_c::calculate()
{
// A productie
// Machine 1
this->A3 = productionCost(this->Standard, this->A2);
this->A4 = this->A2 * this->A3;
// Machine 2
this->A6 = productionCost(this->Standard, this->A5);
this->A7 = this->A5 * this->A6;
// Machine 3
this->A9 = productionCost(this->Standard, this->A8);
this->A10 = this->A8 * this->A9;
// Totale productionCost
this->A11 = this->A4 + this->A7 + this->A10;
this->A12 = this->A2 + this->A5 + this->A8;
this->A13 = static_cast<float>(this->A11) / static_cast<float>(this->A12);
// B marketing
// ingevuld door constructor
// C Bestellingen
if (this->Standard == MachineStandard::Standard)
this->C1 = 2000;
else if (this->Standard == MachineStandard::Luxe)
this->C1 = 400;
this->C2 = AdditionalOrdersSalesPrice(this->Standard, this->B1);
this->C3 = AdditionalOrdersProfitMargin(this->Standard, this->B2);
this->C4 = AdditionalOrdersQuality(this->Standard, this->B3);
this->C5 = AdditionalOrdersadvertisement(this->Standard, 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 (Standard == MachineStandard::Standard)
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::getResult(void) const
{
return this->D10;
}
float Starters_c::productionCostLuxe(unsigned int productionQuantity)
{
if (productionQuantity == 0)
return 0;
if (productionQuantity <= 600)
return 31.50;
if (productionQuantity <= 650)
return 31.30;
if (productionQuantity <= 700)
return 30.80;
if (productionQuantity <= 750)
return 29.80;
if (productionQuantity <= 800)
return 28.10;
if (productionQuantity <= 850)
return 26.50;
if (productionQuantity <= 900)
return 25.20;
if (productionQuantity <= 950)
return 24.40;
if (productionQuantity <= 1000)
return 24.00;
if (productionQuantity <= 1050)
return 24.40;
if (productionQuantity <= 1100)
return 25.20;
if (productionQuantity <= 1150)
return 26.50;
if (productionQuantity <= 1200)
return 28.10;
if (productionQuantity <= 1250)
return 29.80;
if (productionQuantity <= 1300)
return 30.80;
if (productionQuantity <= 1350)
return 31.30;
if (productionQuantity >= 1400 && productionQuantity <= 2000)
return 31.50;
debugErrorln("productionCostStandard: productionQuantity " + std::to_string(productionQuantity) + " is not in range");
return -1;
}
float Starters_c::productionCostStandard(unsigned int productionQuantity)
{
if (productionQuantity == 0)
return 0;
if (productionQuantity <= 1200)
return 27.50;
if (productionQuantity <= 1300)
return 27.30;
if (productionQuantity <= 1400)
return 26.80;
if (productionQuantity <= 1500)
return 25.80;
if (productionQuantity <= 1600)
return 24.10;
if (productionQuantity <= 1700)
return 22.50;
if (productionQuantity <= 1800)
return 21.20;
if (productionQuantity <= 1900)
return 20.40;
if (productionQuantity <= 2000)
return 20.00;
if (productionQuantity <= 2100)
return 20.40;
if (productionQuantity <= 2200)
return 21.20;
if (productionQuantity <= 2300)
return 22.50;
if (productionQuantity <= 2400)
return 24.10;
if (productionQuantity <= 2500)
return 25.80;
if (productionQuantity <= 2600)
return 26.80;
if (productionQuantity <= 2700)
return 27.30;
if (productionQuantity >= 28000 && productionQuantity <= 4000)
return 27.50;
debugErrorln("productionCostLuxe: productionQuantity " + std::to_string(productionQuantity) + " is not in range");
return -1;
}
float Starters_c::productionCost(Starters_c::MachineStandard Standard, unsigned int productionQuantity)
{
switch (Standard)
{
case MachineStandard::Standard:
return productionCostStandard(productionQuantity);
break;
case MachineStandard::Luxe:
return productionCostLuxe(productionQuantity);
break;
default:
return -1;
break;
}
}
int Starters_c::AdditionalOrdersSalesPriceStandard(unsigned int salesPrice)
{
if (salesPrice == 34)
return 600;
if (salesPrice == 35)
return 540;
if (salesPrice == 36)
return 480;
if (salesPrice == 37)
return 420;
if (salesPrice == 38)
return 360;
if (salesPrice == 39)
return 300;
if (salesPrice == 40)
return 240;
if (salesPrice == 41)
return 180;
if (salesPrice == 42)
return 120;
if (salesPrice == 43)
return 60;
if (salesPrice == 44)
return 0;
debugErrorln("AdditionalOrdersSalesPriceStandard: salesPrice " + std::to_string(salesPrice) + " is not in rage");
return -1;
}
int Starters_c::AdditionalOrdersSalesPriceLuxe(unsigned int salesPrice)
{
if (salesPrice == 95)
return 10;
if (salesPrice == 96)
return 9;
if (salesPrice == 97)
return 8;
if (salesPrice == 98)
return 7;
if (salesPrice == 99)
return 6;
if (salesPrice == 100)
return 5;
if (salesPrice == 101)
return 4;
if (salesPrice == 102)
return 3;
if (salesPrice == 103)
return 2;
if (salesPrice == 104)
return 1;
if (salesPrice == 105)
return 0;
debugErrorln("AdditionalOrdersSalesPriceLuxe: salesPrice " + std::to_string(salesPrice) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersSalesPrice(Starters_c::MachineStandard Standard, unsigned int salesPrice)
{
switch (Standard)
{
case MachineStandard::Standard:
return AdditionalOrdersSalesPriceStandard(salesPrice);
break;
case MachineStandard::Luxe:
return AdditionalOrdersSalesPriceLuxe(salesPrice);
break;
default:
return -1;
break;
}
}
int Starters_c::AdditionalOrdersProfitMarginStandard(unsigned int profitMargin)
{
if (profitMargin == 15)
return 30;
if (profitMargin == 20)
return 40;
if (profitMargin == 25)
return 50;
if (profitMargin == 30)
return 60;
if (profitMargin == 35)
return 70;
if (profitMargin == 40)
return 80;
if (profitMargin == 45)
return 90;
if (profitMargin == 50)
return 100;
if (profitMargin >= 15 && profitMargin <= 50)
return profitMargin * 100 / 50;
debugErrorln("AdditionalOrdersProfitMarginLuxe: profitMargin " + std::to_string(profitMargin) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersProfitMarginLuxe(unsigned int profitMargin)
{
if (profitMargin == 25)
return 375;
if (profitMargin == 30)
return 450;
if (profitMargin == 35)
return 525;
if (profitMargin == 40)
return 600;
if (profitMargin == 45)
return 675;
if (profitMargin == 50)
return 750;
if (profitMargin >= 25 && profitMargin <= 50)
return profitMargin * 750 / 50;
debugErrorln("AdditionalOrdersProfitMarginLuxe: profitMargin " + std::to_string(profitMargin) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersProfitMargin(MachineStandard Standard, unsigned int profitMargin)
{
switch (Standard)
{
case MachineStandard::Standard:
return AdditionalOrdersProfitMarginStandard(profitMargin);
break;
case MachineStandard::Luxe:
return AdditionalOrdersProfitMarginLuxe(profitMargin);
break;
default:
return -1;
break;
}
}
int Starters_c::AdditionalOrdersQualityStandard(unsigned int budgetQuality)
{
if (budgetQuality == 3000)
return 75;
if (budgetQuality == 4000)
return 100;
if (budgetQuality == 5000)
return 125;
if (budgetQuality == 6000)
return 150;
if (budgetQuality == 7000)
return 175;
if (budgetQuality == 8000)
return 200;
if (budgetQuality == 9000)
return 225;
if (budgetQuality == 10000)
return 250;
if (budgetQuality >= 3000 && budgetQuality <= 10000)
return budgetQuality * 250 / 10000;
debugErrorln("AdditionalOrdersQualityStandard: budgetQuality " + std::to_string(budgetQuality) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersQualityLuxe(unsigned int budgetQuality)
{
if (budgetQuality == 50000)
return 500;
if (budgetQuality == 60000)
return 600;
if (budgetQuality == 70000)
return 700;
if (budgetQuality == 80000)
return 800;
if (budgetQuality == 90000)
return 900;
if (budgetQuality == 100000)
return 1000;
if (budgetQuality >= 5000 && budgetQuality <= 100000)
return budgetQuality * 1000 / 100000;
debugErrorln("AdditionalOrdersQualityLuxe: budgetQuality " + std::to_string(budgetQuality) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersQuality(MachineStandard Standard, unsigned int budgetQuality)
{
switch (Standard)
{
case MachineStandard::Standard:
return AdditionalOrdersQualityStandard(budgetQuality);
break;
case MachineStandard::Luxe:
return AdditionalOrdersQualityLuxe(budgetQuality);
break;
default:
return -1;
break;
}
}
int Starters_c::AdditionalOrdersadvertisementStandard(unsigned int budgetAdvertisement)
{
if (budgetAdvertisement == 25000)
return 1500;
if (budgetAdvertisement == 30000)
return 1800;
if (budgetAdvertisement == 35000)
return 2100;
if (budgetAdvertisement == 40000)
return 2400;
if (budgetAdvertisement == 45000)
return 2700;
if (budgetAdvertisement == 50000)
return 3000;
if (budgetAdvertisement >= 25000 && budgetAdvertisement <= 50000)
return budgetAdvertisement * 3000 / 50000;
debugErrorln("AdditionalOrdersAdvertisementStandard: budgetAdvertisement " + std::to_string(budgetAdvertisement) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersadvertisementLuxe(unsigned int budgetAdvertisement)
{
if (budgetAdvertisement == 25000)
return 375;
if (budgetAdvertisement == 30000)
return 450;
if (budgetAdvertisement == 35000)
return 525;
if (budgetAdvertisement == 40000)
return 600;
if (budgetAdvertisement == 45000)
return 675;
if (budgetAdvertisement == 50000)
return 750;
if (budgetAdvertisement >= 25000 && budgetAdvertisement <= 50000)
return budgetAdvertisement * 750 / 50000;
debugErrorln("AdditionalOrdersAdvertisementLuxe: budgetAdvertisement " + std::to_string(budgetAdvertisement) + " is not in range");
return -1;
}
int Starters_c::AdditionalOrdersadvertisement(MachineStandard Standard, unsigned int budgetAdvertisement)
{
switch (Standard)
{
case MachineStandard::Standard:
return AdditionalOrdersadvertisementStandard(budgetAdvertisement);
break;
case MachineStandard::Luxe:
return AdditionalOrdersadvertisementLuxe(budgetAdvertisement);
break;
default:
return -1;
break;
}
}