Question: C + + Creating StudentRoster Queue Download and Unzip: o Download Queue.zip and unzip the contents. o Take a moment to understand the functioning of

C++ Creating StudentRoster Queue
Download and Unzip:
o Download "Queue.zip" and unzip the contents.
o Take a moment to understand the functioning of the queue.
Implement the StudentRosterQueue.h header file and the driver.cpp program.
Exception Handling:
o Create both EmptyQueue and FullQueue classes to handle exceptions.
Testing in driver.cpp:
o Read an input file and add all records to the queue.
o Print all elements in the queue.
o Dequeue multiple times until the EmptyQueue exception occurs.
o Implement a try-catch statement for handling the exception.
o Whenever a dequeue occurs, print all elements in the current queue.
Students.txt :
Betsy 123456789 A
Sam Spade 234565677 B
Annie Smith 324233456 A
Thomas J. Jones 345344344 A
Allan Adaire 324234234 C
Jennifer Smallville 234234333 A
//Queue.h
#pragma once
#include
using namespace std;
struct NodeType {
char value;
NodeType* next;
};
class Queue {
private:
NodeType* qFront;
NodeType* qRear;
public:
Queue();
//~Queue();
bool isEmpty();
bool isFull();
void enqueue(char);
void dequeue(char& x);
void displayQueue();
};
Queue::Queue()
{
qFront = qRear = NULL;
}
void Queue::displayQueue()
{
NodeType* nodePtr = qFront;
while (nodePtr != NULL)
{
cout << nodePtr->value <<"";
nodePtr = nodePtr->next;
}
}
bool Queue::isEmpty()
{
if (qFront == NULL)
return true;
else
return false;
}
bool Queue::isFull()
{
NodeType* ptr = new NodeType;
if (ptr == NULL)
return true;
else {
delete ptr;
return false;
}
}
void Queue::enqueue(char x)
{
if (isFull()) exit(1);
NodeType* newNode = new NodeType;
newNode->value = x;
newNode->next = NULL;
if (qFront == NULL)
qFront = newNode;
else
qRear->next = newNode;
qRear = newNode;
}
void Queue::dequeue(char &x)
{
if (isEmpty())
exit(1);
x = qFront->value;
NodeType* temp = qFront;
qFront = qFront->next;
delete temp;
}
//QueueTest.cpp
#include
#include "Queue.h"
using namespace std;
int main()
{
Queue q;
char ch;
q.enqueue('a');
q.enqueue('c');
q.enqueue('p');
q.enqueue('d');
q.dequeue(ch);
cout <<"ch: "<< ch << endl;
q.displayQueue();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!