-
Notifications
You must be signed in to change notification settings - Fork 2
/
Results.cpp
112 lines (86 loc) · 2.75 KB
/
Results.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Results.cpp
*
* Created on: Nov 22, 2016
* Author: rocco
*/
#include "Results.h"
Results::Results() : stockFinalPrice(0), money(0), assets(0), lifeCycle(nullptr),
savings(0), numStocks(0) , minPerf(0), maxPerf(0)
{setUpDistributionSet(); parametersForDistr=new GraphAttributes();
parametersForPerfVsPrice=new GraphAttributes();
setUpPerfVsPrice(); }
Results::Results(Queue* life, double price, double moneyIn, double assetsIn,
double savingsIn, double numS) :
lifeCycle(life), stockFinalPrice(price), money(moneyIn),
assets(assetsIn), savings(savingsIn), numStocks(numS),
minPerf(0), maxPerf(0) {setUpDistributionSet();
parametersForDistr=new GraphAttributes(); setUpPerfVsPrice();
parametersForPerfVsPrice=new GraphAttributes();}
Queue* Results::getLifeCycle() { return lifeCycle; }
double Results::getTotalValue()
{
double totalVal = getMoney() + getAssets() + getSavings();
if (totalVal > 1) return totalVal;
else return totalValue;
}
double Results::getFinalPrice() { return stockFinalPrice; }
double Results::getMoney() { return money; }
double Results::getAssets() { return assets; }
double Results::getSavings() { return savings; }
double Results::getNumStocks() { return numStocks; }
double Results::getMin() { return minPerf; }
double Results::getMax() { return maxPerf; }
int Results::getNumberOfOccurencesAt(int position)
{
if (position < 40 && position > -1) { return distribution[position]; }
else { return -100; } // denotes an error
}
void Results::setMin(double minIn) { minPerf = minIn; }
void Results::setMax(double maxIn) { maxPerf = maxIn; }
void Results::setTotalVal(double valIn) { totalValue = valIn; }
void Results::incrementDistributionAt(int position)
{
distribution[position]+=1;
}
void Results::setUpDistributionSet()
{
for (int j=0; j < 40; j++)
{
distribution[j]=0;
}
}
void Results::addToPerfVsPrice(int pos, double data)
{
if (pos < 0 && pos > 40)
{
cout << "Error: Invalid location to add to Performance vs. Price" << endl;
}
else
{
performanceVsPrice[pos]->add(data);
}
}
void Results::setUpPerfVsPrice()
{
for (int j=0; j < 40; j++)
{
performanceVsPrice[j] = new LList();
}
}
double Results::getListAt_PositionAt(int positionInArr, int posInLList)
{
if (positionInArr >= 0 && positionInArr < 40)
{
return performanceVsPrice[positionInArr]->getDataAt(posInLList);
}
else { return -200; } // error
}
int Results::getSizeOfListAt(int pos)
{
return performanceVsPrice[pos]->getSize();
}
GraphAttributes* Results::getAttributesForDistr() { return parametersForDistr; }
GraphAttributes* Results::getAttributesForPerfVsPrice() { return parametersForPerfVsPrice; }
//Results::~Results() { delete parameters; }
// TODO add performance methods