-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.h
More file actions
60 lines (53 loc) · 1.65 KB
/
Copy pathProduct.h
File metadata and controls
60 lines (53 loc) · 1.65 KB
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
/*
Product.h
Name: Yuansheng Lu
Student ID: 136654167
E-mail: ylu140@myseneca.ca
*/
#ifndef SICT_PRODUCT_H__
#define SICT_PRODUCT_H__
#include <iostream>
#include "Streamable.h"
#include "general.h"
namespace sict {
class Product : public Streamable {
char sku_[MAX_SKU_LEN + 1];
char* name_;
double price_;
bool taxed_;
int quantity_;
int qtyNeeded_;
public:
// constructors, destructor and copy operator
Product();
Product(const char* m_sku, const char* m_name, double m_price = 0, int m_qtyNeeded = 0, bool m_taxed = true);
Product(const Product& src);
Product& operator=(const Product& src);
virtual ~Product();
// setters
void sku(const char* sku);
void price(double price);
void name(const char* name);
void taxed(bool taxed);
void quantity(int quantity);
void qtyNeeded(int qtyNeeded);
// getters
const char* sku() const;
double price() const;
const char* name() const;
bool taxed() const;
int quantity() const;
int qtyNeeded() const;
double cost() const;
bool isEmpty() const;
// member operators
bool operator==(const char* sku) const;
int operator+=(int quantity);
int operator-=(int quantity);
};
// helper operators
double operator+=(double& left_operand, const Product& product);
std::ostream& operator<<(std::ostream& ostr, const Product& product);
std::istream& operator>>(std::istream& istr, Product& product);
}
#endif