1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
class Manager
{
private:
vector<Account*>* accounts;
double startValue;
double taxRate;
double inflationRate;
double apr;
Account* minValBond;
Account* minValFund;
Account* maxValFund;
Account* maxValBond;
double avgYldBond;
double avgYldFund;
double avgBond;
double avgFund;
double avgBury;
Manager(double, double, double, double);
string* parseString(Account*);
void printAccount(Account*);
string* yearlyString(Account*, double);
void maxMinBond();
void maxMinFund();
void calcAvg();
void printYearlySingle(int, double, double, Account*, Account*, Account*);
void printYearlyMultiple(int, double, double, Account*, Account*, Account*);
public:
Manager();
~Manager();
void simulateInvestment(float, int, int);
};
void Manager::simulateInvestment(float startingValue, int yearsIn, int runs) {
//accounts->reserve(sizeof(Account*)*runs*3);
for(int n = runs; n > 0; n--) {
Account* fund = new MutualFund("Mutual Fund", startValue, taxRate, inflationRate);
Account* bond = new Bond("Bond", startValue, inflationRate, apr);
Account* burried = new Bury("Burried", startValue, inflationRate);
accounts->push_back(fund);
accounts->push_back(bond);
accounts->push_back(burried);
}
double prevValFund = startValue;
double prevValBond = startValue;
if(runs == 1) {
for(int i = 0; i < yearsIn; i++) {
for(unsigned int n = 0; n < accounts->size(); n++) {
accounts->at(n)->updateValue(1);
}
printYearlySingle(i, prevValFund, prevValBond, accounts->at(0),
accounts->at(1), accounts->at(2));
prevValFund = accounts->at(0)->getValue();
prevValBond = accounts->at(1)->getValue();
}
}
else if(yearsIn != 0) {
//printYearlyMultiple
}
return;
}
|