-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.cpp
More file actions
49 lines (41 loc) · 1.44 KB
/
Copy pathProduct.cpp
File metadata and controls
49 lines (41 loc) · 1.44 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
#include "Product.h"
Product::Product(string a_merchandiseName, double a_price, int a_quantity, bool a_missing)
{
m_merchandiseName = a_merchandiseName;
m_price = a_price;
m_quantity = a_quantity;
m_missing = a_missing;
m_quantitySold = 0;;
}
Product::Product(string a_merchandiseName, int a_quantityAfterSales, bool a_missing) {
m_merchandiseName = a_merchandiseName;
m_quantitySold = a_quantityAfterSales;
m_missing = a_missing;
m_price = 0;
m_quantity = 0;
}
Product::~Product()
{
}
//Adds to the quantity of the merchandise item
int Product::AddingToQuantity(int a_newQuantity) {
return m_quantity += a_newQuantity;
}
//Calculates the quantity of the merchandise item after an amount was sold
int Product::CalculateQuantityAfterSold() {
return m_quantity - m_quantitySold;
}
//Calculates total money taken in from selling the item
double Product::CalculateTotalMoneyTakenIn() {
return m_price * m_quantitySold;
}
//Overloads < operator to use when sorting the products list
//To output in alphabetical order into the Summary file
bool Product::operator <(Product comparisonProduct) {
return this->m_merchandiseName < comparisonProduct.m_merchandiseName;
}
//Overloads > operator to use when sorting the products list
//To output in alphabetical order into the Summary file
bool Product::operator >(Product comparisonProduct) {
return this->m_merchandiseName > comparisonProduct.m_merchandiseName;
}