-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.cpp
More file actions
156 lines (72 loc) · 2.6 KB
/
Customer.cpp
File metadata and controls
156 lines (72 loc) · 2.6 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <iostream>
#include <string>
#include <iostream>
using namespace std;
class Customer{
public:
Customer(); //default constructor
Customer(string name, string device = "unknown", int wait_time = 0); //parameterized constructor
//return: name_
string getName();
//return: defective_device_
string getDevice();
//return: wait_time_
int getWaitTime();
//post: wait_time_ = new_wait_time
void updateWaitTime(int new_wait_time);
private:
string name_;
string defective_device_;
int wait_time_;
}; // end Customer
Customer::Customer(){
cout << "Default constructor is starting" << endl;
}
Customer::Customer(string name, string device, int wait_time){
name_=name;
defective_device_=device;
wait_time_=wait_time;
}
//return: name_
string Customer::getName(){
return name_;
}
string Customer::getDevice(){
return defective_device_;
}
int Customer::getWaitTime(){
return wait_time_;
}
//post: wait_time_ = new_wait_time
void Customer::updateWaitTime(int new_wait_time){
wait_time_=new_wait_time;
};
/*
class GeniusBar{
public:
GeniusBar(); //default constructor
//pre: number_of_customers_ < MAX_NUMBER_OF_CUSTOMERS
//post: add new_customer to genius_bar_ and increment current_wait_time_ by WAIT_TIME_INCREMENT
//return: true if number_of_customers_ < MAX_NUMBER_OF_CUSTOMERS, false otherwise
bool addWaitingCustomer(Customer& new_customer);
//pre: (number_of_customers_ > 0) && (number_of_available_geniuses_ > 0)
//post: decrement number_of_customers_ and number_of_available_geniuses_
//return: true if (number_of_customers_ > 0) && (number_of_available_geniuses_ > 0), false otherwise
bool assignGeniusToCustomer();
//pre: number_of_available_geniuses_ < TOTAL_NUMBER_OF_GENIUSES
//post: increment number_of_available_geniuses
//return: true if number_of_available_geniuses_ < TOTAL_NUMBER_OF_GENIUSES, false otherwise
bool releaseGenius();
//pre: number_of_customers_ > 0
//post: increment the wait time of each customer on the genius_bar by WAIT_TIME_INCREMENT
//return: true if number_of_customers_ > 0, false otherwise
bool updateCustomersWaitTime();
private:
static const int TOTAL_NUMBER_OF_GENIUSES = 3;
static const int MAX_NUMBER_OF_CUSTOMERS = 5;
static const int WAIT_TIME_INCREMENT = 5;
int current_wait_time_;
int number_of_available_geniuses_;
int number_of_customers_;
Customer genius_bar_[MAX_NUMBER_OF_CUSTOMERS];
}; //end GeniusBar*/