-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.cpp
More file actions
42 lines (33 loc) · 770 Bytes
/
Product.cpp
File metadata and controls
42 lines (33 loc) · 770 Bytes
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
// Tyeon Ford
// Product aka parent class
#include "Product.h"
#include <iostream>
using namespace std;
Product::Product(string name, double price, int stock, string description)
: name(name), price(price), stock(stock), description(description) {}
// methods
string Product::getName() const {
return name;
}
double Product::getPrice() const {
return price;
}
int Product::getStock() const {
return stock;
}
string Product::getDescription() const {
return description;
}
bool Product::reduceStock(int quantity) {
if (stock >= quantity) {
stock -= quantity;
return true;
}
return false;
}
void Product::restoreStock(int quantity) {
stock += quantity;
}
bool Product::isInStock() const {
return stock > 0;
}