-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer.cpp
53 lines (44 loc) · 1.38 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
/**
* Customer.cpp
* Customer class includes customerID, lastName, string firstName,
* and vector<string> to store customer history.
*
* @author Olga Kuriatnyk
*/
#include "customer.h"
// explicit constructor
Customer::Customer(int id) { this->customerID = id; }
// @return user ID
int Customer::getID() const { return this->customerID; }
// @return user last name
string Customer::getLastName() const { return this->lastName; }
// @return user first name
string Customer::getFirstName() const { return this->firstName; }
// reads the line from the file and sets the values to this object
void Customer::read(istream &is) { is >> this->firstName >> this->lastName; }
// add note to the customers' history
void Customer::insertHistory(const string &str) {
this->customerHistory.push_back(str);
}
// @return true if customer has borrowd the movie
bool Customer::findHistory(const string &str) {
for (const auto &i : customerHistory) {
if (i == str) {
return true;
}
}
return false;
}
// print customer history
void Customer::printCustomerHistory() const {
cout << "History Customer [" << this->getFirstName() << " "
<< this->getLastName()
<< "] ID [" + to_string(customerID) + "] : " << endl;
if (customerHistory.empty()) {
cout << "\tNo history." << endl;
} else {
for (const auto &i : customerHistory) {
cout << "\t" << i << endl;
}
}
}