-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.h
58 lines (45 loc) · 971 Bytes
/
item.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
#include <string>
using namespace std;
#ifndef _ITEM_H
#define _ITEM_H
class Item {
private:
static int lastId;
int id;
string name;
int price;
int stockCount;
static int getAnId() {
Item::lastId++;
return Item::lastId;
}
public:
Item() {
id = -1;
}
Item(string name, int price, int stockCount = 0) {
this -> id = getAnId();
this -> name = name;
this -> price = price;
this -> stockCount = stockCount;
}
int getId() const {
return id;
}
const string &getName() const {
return name;
}
int getPrice() const {
return price;
}
void setPrice(int price) {
this -> price = price;
}
int getStockCount() const {
return stockCount;
}
void setStockCount(int stockCount) {
this -> stockCount = stockCount;
}
};
#endif