-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStockAccount.h
71 lines (53 loc) · 1.71 KB
/
StockAccount.h
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
/*Name: Pranav Shivkumar
Title: StockAccount.h (Node for DLL header and Stock Portfolio Header)*/
#ifndef StockAccount_h
#define StockAccount_h
#include<map>
#include"Account.h"
class Node
{
friend class StockAccount;
public:
Node(string& name, int n)
:StockSymbol(name), quantity(n) //constructor that initializes the stock symbol and number of stocks
{
this->prev = NULL; //set the prev and next pointers to NULL initially
this->next = NULL;
}
private:
string StockSymbol;
int quantity;
double stkprice;
double nodeval;
string nodestr;
Node* next;
Node* prev;
};
class StockAccount : public Account //public derivation of class StockAccount from base class Account
{
public:
StockAccount();
~StockAccount();
double displayStockPrice(string); //displays the price per share of stock symbol (string)
static double total;
void addNode(Node*); //adds a node to the DLL
void printList(); //print the DLL
Node* sort(Node*, Node*); //sorts the list
//void sort();
Node* split(Node*); //splits the list recursively for merge sort
Node* merge(Node*); //merge sort call
void wrapper();
void displayCurrentPortfolio(); //stores the portfolio in file
void buyShares(string, int, double, BankAccount&); //function to buy shares
void sellShares(string, int, double, BankAccount&); //function to sell shares
void viewGraph(); //function to view the graph (MATLAB interface)
void transactionHistory(); //read from file and print transaction history
virtual void setCashBalance(double);
virtual double getCashBalance();
private:
Node* head;
Node* tail;
int size;
double balance;
};
#endif