customer service simulation
Description
Modify or rewrite the Queue class given to simulate customer arrivals at the Department of Motor Vehicles (DMV) counter.
As customers arrive, they are given a ticket number starting at 1. When a customer service agent is free, the customer with the next ticket number is called. This system results in a FIFO queue of customers. Write a program that implements the queue and simulates customers entering and leaving the queue. Input into the queue should be the ticket number and a getin_time when the ticket was entered into the queue. A ticket and its corresponding getin_time is removed when a customer service agent handles the next customer.
Your program will also save the length of time the last 3 customers spent waiting. Every time a ticket is removed from the queue, update these times and output the average of the last three customers as an estimate wait time.
If nobody is in the queue, output that the line is empty.
Queue Class
Modify or rewrite the following queue class implementation, or the one in display 13.21 through 13.23:
What to Submit
Submit for this lab your program file in .cpp and/or .h.
Bonus Points
Add a try-throw-catch block in your code for a 20 point bonus. Please claim the bonus by answering Q2 in in the Problems Encountered & Bonus Claim section.
Requirements
- Impeccable comments and programming style
- Your code will not cause any runtime errors such as segmentation faults
- Answer the questions in the Problems Encountered & Bonus Claim section
Tips
- Consider adding member variables in your modified Queue class for wait time calculation
- Use visual aids to help you understand your plan for the function
- Consider boundary cases, such as:
- When the list is empty
- When the list has only one node
- You might want to “rewrite” or “copy/type out” other functions that are already implemented to solidify your understanding with linked list first
Demo
The line is empty.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
1
Customer 1 entered the queue at time 100000044.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
1
Customer 2 entered the queue at time 100000049.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
1
Customer 3 entered the queue at time 100000055.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
2
Customer 1 is being helped at time 100000069. Wait time = 25
seconds.
The estimated wait time for customer 2 is 25 seconds.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
2
Customer 2 is being helped at time 100000076. Wait time = 27
seconds.
The estimated wait time for customer 3 is 26 seconds.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
1
Customer 4 entered the queue at time 100000080.
Enter '1' to simulate a customer's arrival, '2' to help the
next customer, or '3' to quit.
2
Customer 3 is being helped at time 100000099. Wait time = 44
seconds.
The estimated wait time for customer 4 is 32 seconds.