//I need help on where to go from here, mostly in the main.
//The instructions and requirements can be found in the attachment.
/*********************************
Queue header file
********************************/
#ifndef QUEUE_H
#define QUEUE_H
#include <iostream>
using namespace std;
class Queue
{
private:
class QueueNode
{
friend class Queue;
int value;
QueueNode *next;
QueueNode(int value1, QueueNode *next1 = NULL)
{
value = value1;
next = next1;
}
};
QueueNode *front;
QueueNode *rear;
public:
Queue();
~Queue();
void enqueue(int);
void dequeue(int &);
bool isEmpty();
void clear();
};
#endif
/**********************************
Queue cpp
***********************************/
#include <iostream>
#include <iomanip>
#include "queue.h"
using namespace std;
Queue::Queue ()
{
front = NULL;
rear = NULL;
}
Queue::~Queue()
{
clear();
}
void Queue::enqueue(int num)
{
if (isEmpty())
{
front = new QueueNode(num);
rear = front;
}
}
void Queue::dequeue(int &num)
{
QueueNode *temp;
if (isEmpty())
{
cout<<"The queue is empty.\n";
exit(1);
}
else
{
num = front->value;
temp=front;
front=front->next;
delete temp;
}
}
bool Queue::isEmpty()
{
if (front == NULL)
return true;
else
return false;
}
void Queue::clear()
{
int value;
while(!isEmpty())
dequeue(value);
}
/***************************
main cpp
***************************/
#include <iostream>
#include <iomanip>
using namespace std;
#include <time.h>
#include "queue.h"
int main()
{
int option;
Queue iQueue;
int num = 1;
long seconds;
seconds = static_cast<long>(time(NULL));
cout<<"The line is empty"<<endl;
do {
cout<<"Enter '1' to simulate a customer's arrival, '2' to help the next customer, or '3' to quit"<<endl;
cin>>option;
if (option == 1)
{
cout<<"Customer "<< num <<" entered the queue at time "<<seconds<<endl;
iQueue.enqueue(num);
num++;
}
else if (option == 2)
{
cout<<"Customer "<< num <<" is being helped at time "<<seconds<<endl;
//cout<<"Wait time = "<< <<"seconds "<<endl;
}
else
{
break;
}
}while (option != 3);
while (!iQueue.isEmpty())
{
int value;
iQueue.dequeue(value);
cout<<value<<" ";
}
system("pause");
return 0;
}