-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerQueue.cpp
More file actions
49 lines (44 loc) · 1.79 KB
/
CustomerQueue.cpp
File metadata and controls
49 lines (44 loc) · 1.79 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
/* Hunter Trautz and Gabe Aponte, CustomerQueue.cpp */
#include "CustomerQueue.h"
/** Removes the customer that is at the head of the queue from the queue and sets the next customer in line as the head
* @Param *queue pointer to the queue that we want to remove the head customer from
* @Return void, removes the head of the queue
*/
void removeCustomerHelper(CustomerQueue *queue){
//if the head of the queue is not pointintg to another customer, initiallize a new one so that the queue
//so that the queue can be mainted
if(queue->nextCustomer == NULL){
queue->nextCustomer = new CustomerQueue();
}
//set the head of the queue to the next customer in line
*queue = *queue->nextCustomer;
}
/** Removes the customer that is at the head of the queue from the queue and sets the next customer in line as the head
* This function is so that you can easily call removeCustomerHelper on an object
* @Return void, removes the head of the queue
*/
void CustomerQueue::removeCustomer(){
removeCustomerHelper(this);
}
/** Adds a customer to the end of the queue
* @Param *customer pointer to the customer that we want to add
* @Param *queue pointer to the queue that we want to add the customer to
* @Return void, adds the customer to the end of the queue
*/
void addCustomerHelper(Customer *customer, CustomerQueue *queue){
if(queue->customer == NULL){
queue->customer = customer;
} else {
if(queue->nextCustomer == NULL){
queue->nextCustomer = new CustomerQueue();
}
addCustomerHelper(customer, queue->nextCustomer);
}
}
/** adds a customer to the end of the queue
* This function is so that you can easily call addCustomerHelper on an object
* @Return void, adds the customer to the end of the queue
*/
void CustomerQueue::addCustomer(Customer *customer){
addCustomerHelper(customer, this);
}