-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer.cpp
More file actions
101 lines (89 loc) · 2.1 KB
/
Copy pathcustomer.cpp
File metadata and controls
101 lines (89 loc) · 2.1 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
#include "customer.h"
#include "order.h"
#include <iostream>
#include <iomanip>
//----------------------------------------
// Kurucu ve Yıkıcılar
Customer::Customer()
{
name = "";
userID = 0;
email = "";
address = "";
orders = nullptr;
orderCount = 0;
}
Customer::Customer(int userID, const string &name, const string &email, const string &address)
{
this->userID = userID;
this->name = name;
this->email = email;
this->address = address;
orders = nullptr;
orderCount = 0;
}
Customer::~Customer()
{
if (orders != nullptr)
{
delete[] orders;
}
}
//--------------------------------------
// Getter fonksiyonu
string Customer::getAddress() const
{
return address;
}
//----------------------------------------
// Setter fonksiyonu
void Customer::setAddress(const string &addr)
{
address = addr;
}
void Customer::addOrder(Order *newOrder)
{
// Yeni dizi oluştur
Order **temp = new Order *[orderCount + 1];
// Eski siparişleri kopyala
for (int i = 0; i < orderCount; i++)
{
temp[i] = orders[i];
}
// Yeni siparişi ekle
temp[orderCount] = newOrder;
// Eski diziyi sil
delete[] orders;
// Yeni diziyi ata
orders = temp;
orderCount++;
}
void Customer::showOrders() const
{
if (orderCount == 0)
{
cout << "Bu müşteriye ait sipariş yok." << endl;
return;
}
cout << "===== Müşterinin Siparis Gecmisi =====" << endl;
for (int i = 0; i < orderCount; i++)
{
orders[i]->showOrder();
}
}
//------------------------------------------
// Display fonksiyonu
void Customer::displayInfo() const
{
cout << "\n----- Musteri Bilgileri -----" << endl;
cout << left
<< setw(15) << "User ID:"
<< userID << endl
<< setw(15) << "Isim:"
<< name << endl
<< setw(15) << "Email:"
<< email << endl
<< setw(15) << "Adres:"
<< address << endl;
cout << "----------------------------" << endl;
}