-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.cpp
More file actions
124 lines (64 loc) · 2.03 KB
/
Customer.cpp
File metadata and controls
124 lines (64 loc) · 2.03 KB
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
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "Customer.h"
Customer::Customer(string name, string surname, string email, string address, int phone)
: name(name), surname(surname), email(email), address(address), phone(phone) {}
string Customer::getName() const{
return name;
}
string Customer::getSurname() const{
return surname;
}
string Customer::getEmail() const{
return email;
}
int Customer::getPhone() const{
return phone;
}
string Customer::getAddress() const{
return address;
}
void Customer::setName(const string& name){
this->name = name;
}
void Customer::setSurname(const string& surname){
this->surname = surname;
}
void Customer::setEmail(const string& email){
this->email = email;
}
void Customer::setPhone(const int& phone){
this->phone = phone;
}
void Customer::setAddress(const string& address){
this->address = address;
}
void Customer::addOrder(Order* order){
order->set_customer(this);
orders.push_back(order);
}
void Customer::removeOrder(Order* order){
auto it = find(orders.begin(), orders.end(), order);
if (it != orders.end()) {
orders.erase(it);
}
}
int Customer::getOrderCount() const{
return orders.size();
}
void Customer::print() const{
cout << "Customer Information:\n";
cout << "Name: " << name << " " << surname << endl;
cout << "Email: " << email << endl;
cout << "Address: " << address << endl;
cout << "Phone: " << phone << endl;
cout << "Number of Orders: " << orders.size() << endl;
if (!orders.empty()) {
cout << "Orders:\n";
for (auto order : orders){
cout << " - " << order->get_event() << endl;
}
}
}