-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstockitem.h
52 lines (41 loc) · 1.48 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
// File: stockitem.h
// Date: 2016-02-27
// Description: Declaration of a StockItem class
#pragma once
#define DESC_MAX_LENGTH 30
#include <string>
using namespace std;
class StockItem {
private:
int sku; // unique identifier for stock keeping unit, range [10000, 99999] (5 digits)
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, string desc, double p);
// Accessors
int GetSKU() const;
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(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);
};