forked from ChicoState/NotPOSPOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.cpp
More file actions
44 lines (36 loc) · 662 Bytes
/
order.cpp
File metadata and controls
44 lines (36 loc) · 662 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
43
44
#include "order.h"
order::order() {
tax = 0.0725;
closed = false;
}
order::order(double tax) {
this->tax = tax;
closed = false;
}
void order::addItem(item i) {
if( !closed )
{
itemList.push_back(i);
}
notifyObservers();
}
std::vector<item> order::getItems() {
return itemList;
}
double order::getSubtotal() {
double subtotal = 0;
for(int i = 0; i < itemList.size(); i++) {
subtotal += itemList[i].getPrice();
}
return subtotal;
}
double order::getTax() {
return tax;
}
double order::getTotal() {
return getSubtotal() * (1 + tax);
}
double order::balance(double paid) {
closed = true;
return getTotal() - paid;
}