-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.cpp
134 lines (107 loc) · 2.65 KB
/
Customer.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// PROIekt - symulacja supermarketu
//
// Created by Ksawery Chodyniecki and Paweł Müller.
//
#include "Customer.hpp"
using namespace std;
Customer::Customer(unsigned short argID, bool argIsBusiness, string argName, string argTaxNumber, string argStreet, string argBuildingNumber, string argPostcode, string argCity, string argCountry) {
basket.clear();
ID = argID;
isBusiness = argIsBusiness;
name = argName;
taxNumber = argTaxNumber;
street = argStreet;
buildingNumber = argBuildingNumber;
postcode = argPostcode;
city = argCity;
country = argCountry;
}
// Getters:
unsigned short Customer::getID() const {
return ID;
}
bool Customer::getIsBusiness() const {
return isBusiness;
}
string Customer::getName() const {
return name;
}
string Customer::getTaxNumber() const {
return taxNumber;
}
string Customer::getStreet() const {
return street;
}
string Customer::getBuildingNumber() const {
return buildingNumber;
}
string Customer::getPostcode() const {
return postcode;
}
string Customer::getCity() const {
return city;
}
string Customer::getCountry() const {
return country;
}
map<Product*, unsigned short> Customer::getBasket() const {
return basket;
}
unsigned long Customer::getBasketSize() const {
return basket.size();
}
//Setters:
void Customer::setID(unsigned short newID) {
ID = newID;
return;
}
void Customer::setIsBusiness(bool newIsBusiness) {
isBusiness = newIsBusiness;
return;
}
void Customer::setName(string newName) {
name = newName;
return;
}
void Customer::setTaxNumber(string newTaxNumber) {
taxNumber = newTaxNumber;
return;
}
void Customer::setStreet(string newStreet) {
street = newStreet;
return;
}
void Customer::setBuildingNumber(string newBuildingNumber) {
buildingNumber = newBuildingNumber;
return;
}
void Customer::setPostcode(string newPostcode) {
postcode = newPostcode;
return;
}
void Customer::setCity(string newCity) {
city = newCity;
return;
}
void Customer::setCountry(string newCountry) {
country = newCountry;
return;
}
// Tools to edit Basket:
void Customer::addToBasket(Product* argProduct, unsigned short argQuantity) {
if (basket.find(argProduct) == basket.end())
basket.insert(pair<Product*, unsigned short>(argProduct, argQuantity));
else
basket[argProduct] += argQuantity;
argProduct -> decQuantity(argQuantity);
}
void Customer::removeFromBasket(Product* argProduct, unsigned short argQuantity) {
basket.erase(argProduct);
argProduct -> addQuantity(argQuantity);
return;
}
void Customer::clearBasket() {
basket.clear();
return;
}