in c plus plus Create a class named waitList that can store a name and number of
ID: 666883 • Letter: I
Question
in c plus plus
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
struct Queue
char name[80];
};
class WailtList {
private:
int front;
int rear;
Passenger passengers[MAX];
public:
CQueue();
bool IsEmpty(void);
bool IsFull(void);
void Enqueue(Passenger);
Passenger Front(void);
void Dequeue(void);
};
#include <iostream>
#include <string>
#include "cqueue.h"
using namespace std;
enum choice { BOOKED, WAITING };
const int LINES = 2;
int showMenu(void);
void addPassenger(CQueue*);
void deletePassenger(CQueue*);
void showPassengers(CQueue*);
int main (void)
{
CQueue qPassengers[LINES];
int x;
do{
x = showMenu();
switch (x)
{
case 1: addPassenger(qPassengers);
break;
case 2: deletePassenger(qPassengers);
break;
case 3: showPassengers(qPassengers);
break;
}
} while (x != 4);
return 0;
}
int showMenu(void)
{
int select;
cout << "Menun";
cout << "========n";
cout << "1. Add Passengern";
cout << "2. Delete Passengern";
cout << "3. Show Passengersn";
cout << "4. Exitn";
cout << "Enter choice: ";
cin >> select;
return select;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.