Question
Part 1: Download the files queueOfStrings.cpp, and StringQueue.h. There are two struct definitions in StringQueue.h, but they are incomplete. Your task for this exercise is
Part 1:
Download the files queueOfStrings.cpp, and StringQueue.h. There are two struct definitions in StringQueue.h, but they are incomplete. Your task for this exercise is to complete them. It is just a basic queue data structure, but instead of int or long, the queue stores string elements. As usual, just make it so that the file queueOfStrings.cpp compiles and runs correctly. Files are below:
------QueOfStrings.cpp------------
#include#include "StringQueue.h" using namespace std; int main(int argc, const char * argv[]) { Queue queue; queue.push("Jack"); queue.push("Jill"); queue.push("Jane"); queue.push("John"); while (!queue.isEmpty()) { cout << queue.pop() << endl; } return 0; }
----StringQue.h-----------
#ifndef Queue_h #define Queue_h #includestruct Link { // Provide your code here... }; struct Queue { // Provide your code here... }; #endif
----------------------------------------------------------------------------------------------------
Part 2:
You have been given the task of creating a waiting list application that keeps track of people who are waiting for their turn. It should have the capability of adding people to the waiting list, checking whose turn it is next, serving a customer (which is just removing them from the waiting list), and finally at closing time, your program should report if there were any customers who are still waiting in line, so that they can be advised to come back tomorrow.
You are required to use a Queue, and the apporpriate Queue operations to complete all the tasks in this exercise. You may assume that a completed StringQueue.h is in your working directory, and you should include it.
If you do not use the Queue data structure defined in StringQueue.h in an appropriate manner, your solution will be marked as incorrect, even if your produced output matches the output we expect.
When your program starts up, it should wait for input from the user. The following input commands need to be handled:
- a: A new customer has arrived, read in a string representing the customer's name, and add them to the waiting list. Print a message saying: [name] arrived where [name] is the name of the customer
- s: It is time to serve the next customer in the list. If there is a next customer in line, print a message saying: Now serving [name] where [name] is the customer's name. Since this customer is now being served, they should be removed from the waiting list. If there is no next customer in line, print the message: No customers waiting
- n: Who is next in line? If there is at least one person still waiting in line, print out a message saying: Next in line: [name] where [next] is the name of the customer whose turn is next. If there is no next person in line, then print out the message: The waiting list is empty
- q: It is closing time. Check to see if there are any customers who are still witing. If that is the case print out the following: Come back tomorrow: [name] ... [name] Basically, the message followed by a list of everyone who is still waiting. In the process of lisitng the customers who are still waiting, they should also be removed from the list one by one. If there is no one waiting at closing time, do not print out the message advising customers to come back tomorrow
Finally, print out a message saying: Closing up now. and then terminate your application.
It is extremely important that you print the messages without spelling errors and with the punctuation exactly as it appears in the instructions. For example, there is a period at the end of the last message. Look at the sample output and make sure your matches.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started