-
Notifications
You must be signed in to change notification settings - Fork 6
/
Stock.cpp
60 lines (45 loc) · 1.18 KB
/
Stock.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
/*
* Stock.cpp
*
* Created on: Dec 25, 2017
* Author: ethanyoung
*/
#include "Stock.h"
#include <iostream>
using namespace std;
//Constructor for stock
Stock::Stock(string stockName) {
numDays = 0;
name = stockName;
}
// Make sure to free all the memory
Stock::~Stock() {
// TODO Auto-generated destructor stub
}
// Buys the stock
bool Stock::buy() {
cout << "Implement buy stock." << endl;
return true;
}
// Sells the stock
bool Stock::sell() {
cout << "Implement sell stock." << endl;
return true;
}
//Converts date to an int for indexing the maps
int Stock::convertDate(tm* Date) {
return (Date->tm_mon + 1) *1000000 + Date->tm_mday*10000 + Date->tm_year;
}
//Return -1 if factor doesnt exist
float Stock::getFactorValue(std::string factorName, tm* Date) {
return Factors.at(factorName).getValue(convertDate(Date));
}
void Stock::setFactorValue(std::string factorName, tm* Date, float value) {
Factors.find(factorName)->second.setValue(convertDate(Date), value);
}
void Stock::addFactor(Factor factor) {
Factors.insert(pair<string,Factor>(factor.getName(),factor));
}
string Stock::getName() {
return name;
}