-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStock.h
52 lines (41 loc) · 1.15 KB
/
Stock.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
#ifndef STOCK_H
#define STOCK_H
#include <string>
#include <iostream>
/*
* class Stock encapsulates a stock position
* including name, ticker, price, and numshares
* Provides methods used by the stock_server to
* to support buying and selling of shares.
*/
using namespace std;
class Stock {
friend ostream& operator<<(ostream& os, const Stock& st);
friend ostream& operator<<(ostream& os, const Stock* st);
public:
Stock():name("null"), ticker("nul"), quantity(0), price(0.0){};
Stock(string n, string sym, int num, double pr);
Stock(const Stock& s);
const string getKey() const;
const string getName() const;
const string getTicker() const;
double getPrice() const;
int getQuantity() const;
void setName(string s);
void setTicker(string s);
void setPrice(double p);
void setQuantity(int s);
// relational operators
bool operator>(const Stock other) const;
bool operator<(const Stock other) const;
bool operator==(const string key) const;
bool operator==(const Stock other) const;
bool operator>=(const Stock other) const;
bool operator<=(const Stock other) const;
private:
string name;
string ticker;
double price;
int quantity;
};
#endif