You will design a program to keep track of a restaurants waitlist using a queue
ID: 666547 • Letter: Y
Question
You will design a program to keep track of a restaurants waitlist using a queue implemented with a linked list. Make sure to read pages 1215-1217 and 1227-1251
Create a class named waitList that can store a name and number of guests. Use constructors to automatically initialize the member variables.
·
Add the following operations to your program:
Return the first person in the queue
Return the last person in the queue
Add a person to the queue
Delete a person from the queue
Create a main program to test your class. Your main program should contain the following options. Create a menu for your options.
Add a guest (adds the reservation name and number of guests)
Delete a guest (the user must give you the name to delete, the list may be empty or the guest may not be in the list)
Show last guest waiting (return NONE if the queue is empty)
Show first guest waiting (return NONE if the queue is empty)
Exit
Explanation / Answer
enum status(WAIT,CALL);
typedef struct restaurant
{
//stuff
}list;
//I call pop in the main as follows:
pop(&head, &tail);
void pop(list** head, list** tail)
{
list* temp = *head;
int tableSize;
if(*head == *tail && *tail == NULL)
{
printf("The queue is empty... exitting program... ");
exit(EXIT_FAILURE);
}
printf("What is the table size? ");
scanf(" %d", &tableSize);
if(temp->groupSize > tableSize || temp->waitStatus == CALL)
while(temp->groupSize > tableSize || temp->waitStatus == CALL)
temp = temp->nextNode;
else
*head = (*head)->nextNode;
if(*tail == temp)
*tail = (*tail)->nextNode;
free(temp);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.