-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFund.cpp
112 lines (91 loc) · 2.44 KB
/
Fund.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
/*
* Fund.cpp
*
* Created on: Dec 28, 2017
* Author: ethanyoung
*/
#include "Fund.h"
#include "Stock.h"
#include <string>
#include <iostream>
#include <exception>
using namespace std;
/**
* This class is meant to represent the fund as a whole. This
* will allow the manager and investors to see statistics regarding
* the entire find without having to generate it each time from
* the individual investors.
*
* <p>Bugs: (a list of bugs and other problems)
*
* @author E
*/
Fund::Fund() {
stockList = new map<string,Stock>();
}
Fund::~Fund() {
// TODO Auto-generated destructor stub
}
void Fund::addStock(Stock stock) {
stockList->insert(pair<string,Stock>(stock.getName(),stock));
}
void Fund::addInvestor(Investor investor) {
investorList.insert(pair<string,Investor>(investor.getUsername(),investor));
}
bool Fund::stockExists(Stock stock) {
map<string, Stock>::iterator it;
for ( it = stockList->begin(); it != stockList->end(); it++ )
{
//Second is the value
if (it->second.getName() == stock.getName()) {
return true;
}
}
return false;
}
Stock* Fund::getStock(std::string stockName) {
map<string, Stock>::iterator it;
for ( it = stockList->begin(); it != stockList->end(); it++ )
{
if (it->second.getName() == stockName) {
return &(it->second);
}
}
return &(it->second);
}
map<std::string, Stock>* Fund::getStockList() {
return stockList;
}
//Just for testing
void Fund::printStocks() {
map<string, Stock>::iterator it;
for ( it = stockList->begin(); it != stockList->end(); it++ )
{
cout << it->second.getName() << endl;
}
}
//Just for testing
void Fund::printInvestors(string factorName) {
map<string, Investor>::iterator it;
for ( it = investorList.begin(); it != investorList.end(); it++ )
{
cout << it->second.getUsername() << " " << it->second.getFactorValue(factorName) << endl;
}
}
bool Fund::checkCredentials(string username, string password) {
cout << "Checking Credentials in Fund" << endl;
map<string, Investor>::iterator it;
for ( it = investorList.begin(); it != investorList.end(); it++ )
{
if (it->second.getUsername() == username && it->second.getPassword() == password) {
return true;
}
}
return false;
}
void Fund::setDateList(vector<tm*> *dl) {
dateList = dl;
}
std::vector<tm*>* Fund::getDateList() {
return dateList;
}