-
Notifications
You must be signed in to change notification settings - Fork 0
/
stockitem.h
59 lines (48 loc) · 1.45 KB
/
stockitem.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
// Description: Declaration of a StockItem class
#ifndef _STOCKITEM_H_
#define _STOCKITEM_H_
#define DESC_MAX_LENGTH 30
#include <string>
class StockItem
{
private:
int sku; // unique identifier for stock keeping unit, range [10000, 99999] (5 digits)
std::string description; // product name, maximum length of
double price; // retail price of product
int stock; // number of units in stock
public:
// Default constructor
StockItem();
/**
*Parameterized constructor
*Need to specify SKU, description, and price.
*Stock is defaulted to 0;
*/
StockItem(int skuid, std::string desc, double p);
// Accessors
int GetSKU() const;
std::string GetDescription() const;
double GetPrice() const;
int GetStock() const;
// Mutators
/**
*boolean return values - return true for successful update, false if
*argument is invalid (i.e. negative price/stock/SKU)
*sku cannot be modified
*/
bool SetDescription(std::string newdesc);
bool SetPrice(double newprice);
bool SetStock(int amount);
/**
*overloaded operators
*return (in)equality on sku field only
*/
bool operator==(const StockItem& item) const;
bool operator!=(const StockItem& item) const;
bool operator>(const StockItem& item) const;
bool operator<(const StockItem& item) const;
bool operator>=(const StockItem& item) const;
bool operator<=(const StockItem& item) const;
StockItem& operator=(const StockItem& item);
};
#endif