-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.cpp
96 lines (80 loc) · 2.05 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
#include <iostream>
#include "Customer.h"
#include "linkedList.h"
using namespace std;
/*void Customer::SearchOrderList(string title, bool& found, nodeType<Order>*& current) const
{
found = false;
while (current != nullptr && !found)
{
if (current->info.getTitle() == title)
found = true;
else
current = current->link;
}
}*/
ostream& operator<<(ostream& osObject, const Customer& customer)
{
osObject << setw(10) << left << "Name:";
osObject << setw(50) << left << customer.name << endl;
osObject << setw(10) << left << "Address:";
osObject << setw(50) << left << customer.address << endl;
osObject << setw(10) << left << "Email:";
osObject << setw(50) << left << customer.email << endl << endl;
osObject << "---------- Book Orders ---------- :" << endl;
osObject << customer.orders;
return osObject;
}
Customer::Customer()
{
name = "";
address = "";
email = "";
}
Customer::Customer(string customerName, string addr, string customerEmail,OrderList customerOrders)
{
name = customerName;
address = addr;
email = customerEmail;
orders = customerOrders;
}
OrderList Customer::getOrders()
{
return orders;
}
void Customer::AddOrder(Order newOrder)
{
orders.AddOrder(newOrder);
}
void Customer::updateOrders(string title, int number)
{
orders.UpdateOrder(title, number);
}
void Customer::cancelOrder(string title)
{
orders.CancelOrder(title);
}
string Customer::getCustomerName()
{
return name;
}
string Customer::getAddress()
{
return address;
}
string Customer::getEmail()
{
return email;
}
double Customer::checkoutOrders()
{
return orders.CalculateSubtotal();
}
bool Customer::operator==(const Customer& otherCustomer) const
{
return (name == otherCustomer.name && address == otherCustomer.address && email == otherCustomer.email);
}
bool Customer::operator!=(const Customer& otherCustomer) const {
return (name != otherCustomer.name || address != otherCustomer.address ||
email != otherCustomer.email);
}