Verified:

Celphi Game profile

Member
EE Patron
6349

Oct 21st 2023, 22:37:20


#include <iostream>
#include <unordered_map>
#include <string>

class PrivateMarket
{
public:
int64_t m_troops_cost{ 0 };
int64_t m_jets_cost{ 0 };
int64_t m_turrets_cost{ 0 };
int64_t m_tanks_cost{ 0 };

int64_t m_troops_available{ 0 };
int64_t m_jets_available{ 0 };
int64_t m_turrets_available{ 0 };
int64_t m_tanks_available{ 0 };

PrivateMarket(std::unordered_map<std::string, int64_t>&);
void convertOilToUnits(int64_t);
int64_t bushelsNeededForAvailableUnits();
int64_t calculateNetworth();
};

PrivateMarket::PrivateMarket(std::unordered_map<std::string, int64_t>& units)
: m_troops_cost{ units["troops_cost"] }
, m_jets_cost{ units["jets_cost"] }
, m_turrets_cost{ units["turrets_cost"] }
, m_tanks_cost{ units["tanks_cost"] }
{}

void PrivateMarket::convertOilToUnits(int64_t oil)
{
m_troops_available = (oil/40)*30;
m_jets_available = (oil/40)*25;
m_turrets_available = (oil/40)*25;
m_tanks_available = (oil/40)*10;
}

int64_t PrivateMarket::bushelsNeededForAvailableUnits()
{
int64_t troops_cost{ m_troops_available*m_troops_cost };
int64_t jets_cost{ m_jets_available*m_jets_cost };
int64_t turrets_cost{ m_turrets_available*m_turrets_cost };
int64_t tanks_cost{ m_tanks_available*m_tanks_cost };

return (troops_cost + jets_cost + turrets_cost + tanks_cost) / 35;
}

int64_t PrivateMarket::calculateNetworth()
{
return (m_troops_available*0.5)
+ (m_jets_available*0.6)
+ (m_turrets_available*0.6)
+ (m_tanks_available*2);
}

int main(int argc, char *argv[])
{
if (argc < 6)
{
std::cout << "Error - Provide amount of oil stocked.\n";
std::cout << "Lowest Possible: Troops -> 77 Jets -> 103 Turrets -> 112 Tanks -> 315\n\n";
std::cout << "ie. calculate [STOCKED_OIL] [TROOP_COST] [JET_COST] [TURRET_COST] [TANK_COST]\n";
std::exit(1);
}

int64_t oil_stocked{ std::stoi(argv[1]) };
int64_t troop_cost{ std::stoi(argv[2]) };
int64_t jet_cost{ std::stoi(argv[3]) };
int64_t turret_cost{ std::stoi(argv[4]) };
int64_t tank_cost{ std::stoi(argv[5]) };

// private market prices
std::unordered_map<std::string, int64_t> pm_prices{
{ "troops_cost", troop_cost },
{ "jets_cost", jet_cost },
{ "turrets_cost", turret_cost },
{ "tanks_cost", tank_cost },
};

PrivateMarket pm{ pm_prices };
pm.convertOilToUnits(oil_stocked);

// bushels needed for available units
int64_t bnfau = pm.bushelsNeededForAvailableUnits();

std::cout << "\n------------------------------------\n";
std::cout << "Private Market Generated" << '\n';
std::cout << "Oil stocked: " << oil_stocked << '\n';
std::cout << "------------------------------------\n";
std::cout << "Units Generated" << '\n';
std::cout << "Troops: " << pm.m_troops_available << '\n';
std::cout << "Jets: " << pm.m_jets_available << '\n';
std::cout << "Turrets: " << pm.m_turrets_available << '\n';
std::cout << "Tanks: " << pm.m_tanks_available << '\n';
std::cout << "Bushels required to buy out PM: " << bnfau << '\n';
std::cout << "Increase in Networth: " << pm.calculateNetworth() << '\n';
std::cout << "\n";
}


Or use: https://www.onlinegdb.com/cSravmannf
Look at the arguments at the bottom to use your own numbers.

It's labeled: "Command line arguments:"

The order is such:
[STOCKED_OIL] [TROOP_COST] [JET_COST] [TURRET_COST] [TANK_COST]

Example output:
------------------------------------
Private Market Generated
Oil stocked: 60000000
------------------------------------
Units Generated
Troops: 45000000
Jets: 37500000
Turrets: 37500000
Tanks: 15000000
Bushels required to buy out PM: 464357142
Increase in Networth: 97500000

NOTE: You may have to scroll up to see this output in output window.



Edited By: Celphi on Oct 21st 2023, 22:43:36
Resistance is futile. You will be assimilated.

KoHeartsGPA Game profile

Member
EE Patron
30,122

Oct 21st 2023, 23:53:08

Thank you Celphi :-)
Mess with me you better kill me, or I'll just take your pride & joy and jack it up
(•_•)

https://youtu.be/...pxFw4?si=mCDXT3t1vmFgn0qn

-=TSO~DKnights~ICD~XI~LaF~SKA=-

S.F. Giants 2010, 2012, 2014 World Series Champions, fluff YEAH!