-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer.cpp
More file actions
executable file
·107 lines (92 loc) · 2.21 KB
/
customer.cpp
File metadata and controls
executable file
·107 lines (92 loc) · 2.21 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
#include "customer.h"
Customer::Customer()
{
}
Customer::Customer(int id, string fName, string lName)
{
this->customerID = id;
this->firstName = fName;
this->lastName = lName;
}
Customer::~Customer()
{
for (vector<Trans*>::iterator it = History.begin(); it != History.end(); it++)
{
delete *it;
}
}
ostream & operator<<(ostream & ostream, const Customer & rhs)
{
ostream << "\tCustomer Name[" << rhs.getFirstName() << " ";
ostream << rhs.getLastName() << "] ";
ostream << "\tCustomer ID[" << rhs.getCustomerID() << "] " << endl;
for (int i = 0; i < rhs.History.size(); i++)
{
ostream << "\t" << rhs.History[i] << endl;
}
return ostream;
}
void Customer::setCustomerData(int id, string f, string l)
{
customerID = id;
firstName = f;
lastName = l;
}
//void Customer::addHistory(string record)
//{
// this->history.push_back(record);
//}
int Customer::getCustomerID() const
{
return this->customerID;
}
string Customer::getFirstName() const
{
return this->firstName;
}
string Customer::getLastName() const
{
return this->lastName;
}
void Customer::printHistory()
{
cout << endl << "----------- printing transactions for customer: " << customerID << " -----------" << endl;
for(vector<Trans*>::iterator it = History.end() - 1; it != History.begin() - 1; --it)
{
cout << " " << (*it)->Action;
cout << " " << *(*it)->m;
}
cout << "----------------------------------------------------------------" << endl << endl;
}
void Customer::borrowedItem(Movie *movie)
{
borrowed.push_back(movie);
Trans * newTrans = new Trans();
newTrans->Action = 'B';
newTrans->m = movie;
History.push_back(newTrans);
}
void Customer::returnedItem(Movie *movie)
{
for(vector<Movie*>::iterator it = borrowed.begin(); it != borrowed.end(); it++)
{
if(*it == movie)
{
borrowed.erase(it);
break;
}
}
Trans * newTrans = new Trans();
newTrans->Action = 'R';
newTrans->m = movie;
History.push_back(newTrans);
}
bool Customer::checkedOut(Movie *movie)
{
for(vector<Movie*>::iterator it = borrowed.begin(); it != borrowed.end(); it++)
{
if(*it == movie)
return true;
}
return false;
}