Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.34 KB | None | 0 0
  1. main.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2.  
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <fstream>
  7. #include <cstdlib>
  8. #include <sstream>
  9. #include <cmath>
  10. #include "Ore.h"
  11. #include "PVal.h"
  12.  
  13. using std::cout;
  14. using std::cin;
  15. using std::endl;
  16. using std::string;
  17. using std::ifstream;
  18.  
  19. void GetUserVals(PVal& Player);
  20. void SetUserOreEff(PVal& Player);
  21. void Output(PVal& Player);
  22. int GetOreEle(string ID);
  23.  
  24. int main()
  25. {
  26.     cout << "Welcome to Raezzor's Mining Profitability Calculator!" << endl;
  27.     cout << "First we need to collect some information!" << endl;
  28.  
  29.     PVal User;
  30.  
  31.     GetUserVals(User);
  32.     SetUserOreEff(User);
  33.  
  34.     ifstream ore_in("ore.txt");
  35.  
  36.     if (!ore_in.is_open())
  37.     {
  38.         cout << "Error opening ore data file!" << endl;
  39.         exit(EXIT_FAILURE);
  40.     }
  41.  
  42.     Ore OreArr[48];
  43.     string tempOreIn;
  44.     string OreID;
  45.     string tempName;
  46.     float tempVol;
  47.     float tempCompVol;
  48.     int tempTrit;
  49.     int tempPye;
  50.     int tempMex;
  51.     int tempIso;
  52.     int tempNoc;
  53.     int tempMeg;
  54.     int tempZyd;
  55.     int tempMor;
  56.     std::stringstream strcon;
  57.  
  58.     for(int i = 0; i < 48; i++)
  59.     {
  60.         OreArr[i].SetMins(0,0,0,0,0,0,0,0);
  61.         OreArr[i].SetVol(0,0);
  62.         OreArr[i].SetSaleVal(0,0,0);
  63.     }
  64.  
  65.      while (getline(ore_in, tempOreIn, ';'))
  66.     {
  67.         strcon << tempOreIn;
  68.         strcon >> OreID >> tempName >> tempVol >> tempCompVol >> tempTrit >> tempPye >> tempMex >> tempIso >> tempNoc >> tempMeg >> tempZyd >> tempMor;
  69.  
  70.         OreArr[GetOreEle(OreID)].SetName(tempName);
  71.         OreArr[GetOreEle(OreID)].SetVol(tempVol, tempCompVol);
  72.         OreArr[GetOreEle(OreID)].SetMins(tempTrit, tempPye, tempMex, tempIso, tempNoc, tempMeg, tempZyd, tempMor);
  73.     }
  74.  
  75.     //get min and ore sale values from user
  76.     //calculate ore min values
  77.     //output ore isk values (ask user which ore they want to see, or all? Or seperate by null/low/high?
  78.  
  79.     for(int i = 0; i < 48; i++)
  80.     {
  81.         OreArr[i].OutAll();
  82.     }
  83.  
  84.     Output(User);
  85.  
  86.     return 0;
  87. }
  88.  
  89.  
  90. void GetUserVals(PVal& Player)
  91. {
  92.  
  93.     cout << "What is the base refine of the station/POS/outpost you might refine at?" << endl;
  94.     cin >> Player.fBaseRef;
  95.     cout << "Thanks! Now what is your ReProcessing skill at?" << endl;
  96.     cin >> Player.fReProc;
  97.     cout << "And what is your Reprocessing Efficiency skill?" << endl;
  98.     cin >> Player.fReProcEff;
  99.     cout << "Do you have a refining implant? If so enter the % grade of it. Otherwise enter 0." << endl;
  100.     float fTempImp;
  101.     cin >> fTempImp;
  102.     Player.fImp = fTempImp/100;
  103.     cout << "What is your standing with the corporation owning the station you are refining at?" << endl << "Note, if using a POS and not a station/outpost enter any value over 6.67." << endl;
  104.     cin >> fTempImp;
  105.     if (fTempImp >= 6.67)
  106.     {
  107.         Player.fTaxRate = 1;
  108.     }
  109.     else
  110.     {
  111.         Player.fTaxRate = 1 - ((5 - (.75 * fTempImp))/100);
  112.     }
  113.     cout << "What is the level of your Veldspar Processing skill?" << endl;
  114.     cin >> Player.fVelProc;
  115.     cout << "And Scordite?" << endl;
  116.     cin >> Player.fScoProc;
  117.     cout << "Pyroxeres?" << endl;
  118.     cin >> Player.fPyrProc;
  119.     cout << "Placioclase?" << endl;
  120.     cin >> Player.fPlaProc;
  121.     cout << "Omber?" << endl;
  122.     cin >> Player.fOmbProc;
  123.     cout << "Kernite?" << endl;
  124.     cin >> Player.fKerProc;
  125.     cout << "Jaspet?" << endl;
  126.     cin >> Player.fJasProc;
  127.     cout << "Hemorphite?" << endl;
  128.     cin >> Player.fHemProc;
  129.     cout << "Hedbergite?" << endl;
  130.     cin >> Player.fHedProc;
  131.     cout << "Gneiss" << endl;
  132.     cin >> Player.fGneProc;
  133.     cout << "Dark Ochre?" << endl;
  134.     cin >> Player.fOchProc;
  135.     cout << "Spodumain?" << endl;
  136.     cin >> Player.fSpoProc;
  137.     cout << "Crokite?" << endl;
  138.     cin >> Player.fCroProc;
  139.     cout << "Bistot?" << endl;
  140.     cin >> Player.fBisProc;
  141.     cout << "Arkonor?" << endl;
  142.     cin >> Player.fArkProc;
  143.     cout << "And lastly, Mercoxit?" << endl;
  144.     cin >> Player.fMerProc;
  145.     cout << "All done! " << endl << endl;
  146.  
  147.     return;
  148. }
  149.  
  150. void SetUserOreEff(PVal& Player)
  151. {
  152.     Player.fVelEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fVelProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  153.     Player.fScoEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fScoProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  154.     Player.fPyrEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fPyrProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  155.     Player.fPlaEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fPlaProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  156.     Player.fOmbEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fOmbProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  157.     Player.fKerEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fKerProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  158.     Player.fJasEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fJasProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  159.     Player.fHemEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fHemProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  160.     Player.fHedEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fHedProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  161.     Player.fGneEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fGneProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  162.     Player.fOchEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fOchProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  163.     Player.fSpoEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fSpoProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  164.     Player.fCroEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fCroProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  165.     Player.fBisEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fBisProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  166.     Player.fArkEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fArkProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  167.     Player.fMerEff = Player.fBaseRef * (Player.fReProc * .03 + 1) * (Player.fReProcEff * .02 + 1) * (Player.fMerProc * .02 + 1) * (1 + Player.fImp) * Player.fTaxRate;
  168.  
  169.     return;
  170. }
  171.  
  172. void Output(PVal& Player)
  173. {
  174.     cout << "Veld refine rate is: " << Player.fVelEff << "%." << endl;
  175.     cout << "Scord refine rate is: " << Player.fScoEff << "%." << endl;
  176.     cout << "Pyro refine rate is: " << Player.fPyrEff << "%." << endl;
  177.     cout << "Plag refine rate is: " << Player.fPlaEff << "%." << endl;
  178.     cout << "Omb refine rate is: " << Player.fOmbEff << "%." << endl;
  179.     cout << "Kern refine rate is: " << Player.fKerEff << "%." << endl;
  180.     cout << "Jasper refine rate is: " << Player.fJasEff << "%." << endl;
  181.     cout << "Hemo refine rate is: " << Player.fHemEff << "%." << endl;
  182.     cout << "Hed refine rate is: " << Player.fHedEff << "%." << endl;
  183.     cout << "Gneiss refine rate is: " << Player.fGneEff << "%." << endl;
  184.     cout << "Dark Ocher refine rate is: " << Player.fOchEff << "%." << endl;
  185.     cout << "Spod refine rate is: " << Player.fSpoEff << "%." << endl;
  186.     cout << "Crok refine rate is: " << Player.fCroEff << "%." << endl;
  187.     cout << "Bis refine rate is: " << Player.fBisEff << "%." << endl;
  188.     cout << "Ark refine rate is: " << Player.fArkEff << "%." << endl;
  189.     cout << "Merc refine rate is: " << Player.fMerEff << "%." << endl;
  190.  
  191.  
  192. }
  193.  
  194. int GetOreEle(string ID)
  195. {
  196.     if (!ID.compare("Vel")) return 0;
  197.     else if (!ID.compare("CVel")) return 1;
  198.     else if (!ID.compare("DVel")) return 2;
  199.     else if (!ID.compare("Sco")) return 3;
  200.     else if (!ID.compare("CSco")) return 4;
  201.     else if (!ID.compare("MSco")) return 5;
  202.     else if (!ID.compare("Pyr")) return 6;
  203.     else if (!ID.compare("Spyr")) return 7;
  204.     else if (!ID.compare("VPyr")) return 8;
  205.     else if (!ID.compare("Pla")) return 9;
  206.     else if (!ID.compare("APla")) return 10;
  207.     else if (!ID.compare("RPla")) return 11;
  208.     else if (!ID.compare("Omb")) return 12;
  209.     else if (!ID.compare("SOmb")) return 13;
  210.     else if (!ID.compare("GOmb")) return 14;
  211.     else if (!ID.compare("Ker")) return 15;
  212.     else if (!ID.compare("LKer")) return 16;
  213.     else if (!ID.compare("FKer")) return 17;
  214.     else if (!ID.compare("Jas")) return 18;
  215.     else if (!ID.compare("PuJas")) return 19;
  216.     else if (!ID.compare("PrJas")) return 20;
  217.     else if (!ID.compare("Hem")) return 21;
  218.     else if (!ID.compare("VHem")) return 22;
  219.     else if (!ID.compare("RHem")) return 23;
  220.     else if (!ID.compare("Hed")) return 24;
  221.     else if (!ID.compare("VHed")) return 25;
  222.     else if (!ID.compare("GHed")) return 26;
  223.     else if (!ID.compare("Gne")) return 27;
  224.     else if (!ID.compare("IGne")) return 28;
  225.     else if (!ID.compare("PGne")) return 29;
  226.     else if (!ID.compare("DOch")) return 30;
  227.     else if (!ID.compare("OnOch")) return 31;
  228.     else if (!ID.compare("ObOch")) return 32;
  229.     else if (!ID.compare("Spo")) return 33;
  230.     else if (!ID.compare("BSpo")) return 34;
  231.     else if (!ID.compare("GSpo")) return 35;
  232.     else if (!ID.compare("Cro")) return 36;
  233.     else if (!ID.compare("SCro")) return 37;
  234.     else if (!ID.compare("CCro")) return 38;
  235.     else if (!ID.compare("Bis")) return 39;
  236.     else if (!ID.compare("TBis")) return 40;
  237.     else if (!ID.compare("MBis")) return 41;
  238.     else if (!ID.compare("Ark")) return 42;
  239.     else if (!ID.compare("CArk")) return 43;
  240.     else if (!ID.compare("PArk")) return 44;
  241.     else if (!ID.compare("Mer")) return 45;
  242.     else if (!ID.compare("MMer")) return 46;
  243.     else if (!ID.compare("VMer")) return 47;
  244.     else
  245.     {
  246.         cout << "Error reading into array. Aborting";
  247.         exit(EXIT_FAILURE);
  248.     }
  249. }
  250.  
  251.  
  252. Ore.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  253.  
  254. #ifndef ORE_H_INCLUDED
  255. #define ORE_H_INCLUDED
  256. #include <string>
  257.  
  258. using std::string;
  259. using std::cout;
  260. using std::endl;
  261. #endif // ORE_H_INCLUDED
  262.  
  263. class Ore
  264. {
  265.  
  266. private:
  267.  
  268.     string sName;
  269.     float fOreMinVal;
  270.     float fOreSaleVal;
  271.     float fOreCompSaleVal;
  272.     float fUncVol;
  273.     float fCompVol;
  274.     int nTri;
  275.     int nPye;
  276.     int nMex;
  277.     int nIso;
  278.     int nNoc;
  279.     int nMeg;
  280.     int nZyd;
  281.     int nMor;
  282.  
  283. public:
  284.  
  285.     Ore(string Name = "None", float UncVol = 0, float CompVol = 0, int Tri = 0, int Pye = 0, int Mex = 0, int Iso = 0, int Noc = 0, int Meg = 0, int Zyd = 0, int Mor = 0)
  286.     {
  287.         sName = Name;
  288.         fUncVol = UncVol * 100;
  289.         fCompVol = CompVol;
  290.         nTri = Tri * 100;
  291.         nPye = Pye * 100;
  292.         nMex = Mex * 100;
  293.         nIso = Iso * 100;
  294.         nNoc = Noc * 100;
  295.         nMeg = Meg * 100;
  296.         nZyd = Zyd * 100;
  297.         nMor = Mor * 100;
  298.     }
  299.  
  300.     void SetMins(int Tri, int Pye, int Mex, int Iso, int Noc, int Meg, int Zyd, int Mor)
  301.     {
  302.         nTri = Tri;
  303.         nPye = Pye;
  304.         nMex = Mex;
  305.         nIso = Iso;
  306.         nNoc = Noc;
  307.         nMeg = Meg;
  308.         nZyd = Zyd;
  309.         nMor = Mor;
  310.         return;
  311.     }
  312.  
  313.     void SetVol(float UncVol, float CompVol)
  314.     {
  315.         fUncVol = UncVol;
  316.         fCompVol = CompVol;
  317.         return;
  318.     }
  319.  
  320.     void SetSaleVal(float OreMinVal, float OreVal, float OreCompVal)
  321.     {
  322.         fOreMinVal = OreMinVal;
  323.         fOreSaleVal = OreVal;
  324.         fOreCompSaleVal = OreCompVal;
  325.         return;
  326.     }
  327.  
  328.     void SetMinVal(float OreMinVal)
  329.     {
  330.         fOreMinVal = OreMinVal;
  331.         return;
  332.     }
  333.  
  334.     void SetOreSaleVal(float OreVal)
  335.     {
  336.         fOreSaleVal = OreVal;
  337.         return;
  338.     }
  339.  
  340.     void SetOreCompVal(float OreCompVal)
  341.     {
  342.         fOreCompSaleVal = OreCompVal;
  343.         return;
  344.     }
  345.  
  346.     void SetName(string Name)
  347.     {
  348.         sName = Name;
  349.         return;
  350.     }
  351.  
  352.     void SetUncvol(float UVol)
  353.     {
  354.         fUncVol = UVol;
  355.         return;
  356.     }
  357.  
  358.     void SetVol(float Vol)
  359.     {
  360.         fCompVol = Vol;
  361.         return;
  362.     }
  363.  
  364.     void SetTri(int Tri)
  365.     {
  366.         nTri = Tri;
  367.         return;
  368.     }
  369.  
  370.     void SetPye(int Pye)
  371.     {
  372.         nPye = Pye;
  373.         return;
  374.     }
  375.  
  376.     void SetMex(int Mex)
  377.     {
  378.         nMex = Mex;
  379.         return;
  380.     }
  381.  
  382.     void SetIso(int Iso)
  383.     {
  384.         nIso = Iso;
  385.         return;
  386.     }
  387.  
  388.     void SetNoc(int Noc)
  389.     {
  390.         nNoc = Noc;
  391.         return;
  392.     }
  393.  
  394.     void SetMeg(int Meg)
  395.     {
  396.         nMeg = Meg;
  397.         return;
  398.     }
  399.  
  400.     void SetZyd(int Zyd)
  401.     {
  402.         nZyd = Zyd;
  403.         return;
  404.     }
  405.  
  406.     void SetMor(int Mor)
  407.     {
  408.         nMor = Mor;
  409.         return;
  410.     }
  411.  
  412.     void OutAll()
  413.     {
  414.         cout << sName << "\t" << fOreMinVal << "\t" << fOreSaleVal << "\t" << fOreCompSaleVal << "\t"
  415.         << fUncVol << "\t" << fCompVol << "\t" << endl
  416.         << nTri << "\t" << nPye << "\t" << nMex << "\t" << nIso << "\t"
  417.         << nNoc << "\t" << nMeg << "\t" << nZyd << "\t" << nMor << endl << endl;
  418.     }
  419. };
  420.  
  421.  
  422. PVal.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  423.  
  424. #ifndef PVAL_H_INCLUDED
  425. #define PVAL_H_INCLUDED
  426.  
  427.  
  428.  
  429. #endif // PVAL_H_INCLUDED
  430.  
  431. struct PVal
  432.  
  433. {
  434.  
  435. public:
  436.  
  437.     float fBaseRef;
  438.     float fReProc;
  439.     float fReProcEff;
  440.     float fVelProc;
  441.     float fScoProc;
  442.     float fPyrProc;
  443.     float fPlaProc;
  444.     float fOmbProc;
  445.     float fKerProc;
  446.     float fJasProc;
  447.     float fHemProc;
  448.     float fHedProc;
  449.     float fGneProc;
  450.     float fOchProc;
  451.     float fSpoProc;
  452.     float fCroProc;
  453.     float fBisProc;
  454.     float fArkProc;
  455.     float fMerProc;
  456.     float fImp;
  457.     float fTaxRate;
  458.     float fVelEff;
  459.     float fScoEff;
  460.     float fPyrEff;
  461.     float fPlaEff;
  462.     float fOmbEff;
  463.     float fKerEff;
  464.     float fJasEff;
  465.     float fHemEff;
  466.     float fHedEff;
  467.     float fGneEff;
  468.     float fOchEff;
  469.     float fSpoEff;
  470.     float fCroEff;
  471.     float fBisEff;
  472.     float fArkEff;
  473.     float fMerEff;
  474.  
  475. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement