-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.cpp
80 lines (76 loc) · 2.29 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
/* Name Miles Spence
Program Description: This is the cpp file for the Customer header file. It creates the constructors, data structures, and actually defines what each function/method does.
The functions are made up of code which are algorithms and variables to solve problems.
A Customer is a name, arrival time, and time to be serviced. In addition, there are getter and setters for all of those parameters.
*/
#ifndef CUSTOMER_CPP
#define CUSTOMER_CPP
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdlib.h>
#include "Customer.h"
using namespace std;
Customer::Customer() {
name = "NONE";
arrival = 0;
service = 0;
}
Customer::Customer(string customerName, int arrivalTime, int serviceTime) {
name = customerName;
arrival = arrivalTime;
service = serviceTime;
}
Customer::Customer(string line) {
//get name
line.append(" ");
name = line.substr(0, line.find(" "));
line.erase(line.begin(), line.begin() + line.find(" ")+1);
//get arrival
string s = line.substr(0, line.find(" "));
//cout << s << endl;
string minutes = s;
string hour = s;
int aTime;
if(s.length() == 3) {
minutes.erase(minutes.begin(), minutes.begin() + 1);
hour.erase(hour.begin() + 1, hour.end());
aTime = atoi(minutes.c_str());
int hours = atoi(hour.c_str());
aTime += (hours*60);
} else {
minutes.erase(minutes.begin(), minutes.begin() + 2);
hour.erase(hour.begin() + 2, hour.end());
aTime = atoi(minutes.c_str());
int hours = atoi(hour.c_str());
aTime += (hours*60);
}
arrival = aTime;
//get service
line.erase(line.begin(), line.begin() + line.find(" ")+1);
s = line.substr(0, line.find(" "));
service = atoi(s.c_str());
}
void Customer::SetName(string customerName) {
name = customerName;
}
void Customer::SetArrival(int arrivalTime) {
arrival = arrivalTime;
}
void Customer::SetService(int serviceTime) {
service = serviceTime;
}
string Customer::GetName() const {
return name;
}
int Customer::GetArrivalTime() const {
return arrival;
}
int Customer::GetServiceTime() const {
return service;
}
void Customer::PrintCustomer() {
cout << name << " " << arrival << " " << service << endl;
}
#endif