Question: I have this code. After entering some inputs it breaks. The picture showa the break point. I added the header file in which the break
I have this code. After entering some inputs it breaks. The picture showa the break point. I added the header file in which the break occurs.
PriorityQueue.h
#pragma once
#ifndef _PRIORITY_QUEUE
#define _PRIORITY_QUEUE
#include "PriorityQueueInterface.h"
#include "LinkedSortedList.h"
#include "PrecondViolatedExcep.h"
template
class SL_PriorityQueue : public PriorityQueueInterface
{
private:
LinkedSortedList
// items in the priority queue
public:
SL_PriorityQueue();
SL_PriorityQueue(const SL_PriorityQueue& pq);
~SL_PriorityQueue();
bool isEmpty() const;
bool add(const ItemType& newEntry);
bool remove();
/** @throw PrecondViolatedExcep if priority queue is empty. */
ItemType peek() const throw(PrecondViolatedExcep);
}; // end SL_PriorityQueue
template
SL_PriorityQueue
{
} // end add
template
SL_PriorityQueue
: slistPtr(new LinkedSortedList
{
} // end add
template
SL_PriorityQueue
{
delete slistPtr;
}
template
bool SL_PriorityQueue
{
return (slistPtr->isEmpty());
}
template
ItemType SL_PriorityQueue
{
if (slistPtr->isEmpty())
throw PrecondViolatedExcep("Empty");
// The highest priority item is at the end of the sorted list
return slistPtr->getEntry(slistPtr->getLength());
}
template
bool SL_PriorityQueue
{
slistPtr->insertSorted(newEntry);
return true;
} // end add
template
bool SL_PriorityQueue
{
// The highest priority item is at the end of the sorted list
return slistPtr->remove(slistPtr->getLength());
} // end remove
#endif
Main.ccp
#pragma once
#include
#include
using namespace std;
#include"PriorityQueue.h"
#include"MVD.h"
#include"LinkedQueue.h"
int main()
{
string tempName;
string temp, temp2, temp3, temp4, temp5;
DMV tempDMV;
int choice, amount, TotalLicense = 0, TotalRegistration = 0, TimeL = 0, TimeR = 0;
char Method;
SL_PriorityQueue
LinkedQueue
LinkedQueue
LinkedQueue
LinkedQueue
cout
cout
cin >> amount;
for (int i = 0; i
{
cout
cin >> tempName;
tempDMV.setName(tempName);
cout
cout R for automovile Registration"
cin >> Method;
tempDMV.setTrans(Method);
SignIn->enqueue(tempDMV);
} // end for
cout
for (int j = 0; j
{
if (SignIn->peekFront().getTrans() == 'L' || SignIn->peekFront().getTrans() == 'l')
{
Renew->add(SignIn->peekFront().getName());
TimeL += 10;
TotalLicense++;
SignIn->dequeue();
} // end if
else if (SignIn->peekFront().getTrans() == 'R' || SignIn->peekFront().getTrans() == 'r')
{
Registation->enqueue(SignIn->peekFront().getName());
TimeR += 10;
TotalRegistration++;
SignIn->dequeue();
} // end else
} // end for
while (!(Renew->isEmpty()))
{
TimeL += 90;
temp = Renew->peek();
Renew->remove();
cout
cin >> Method;
while (Method != '$' && Method != 'c' && Method != 'C')
{
cout
cout
cin >> Method;
} // end while
Cashier->enqueue(temp);
if (Method == 'c' || Method == 'C')
{
TimeL += 40;
cout
Checks->enqueue(temp);
/*Renew->remove();*/
Cashier->dequeue();
} // end if
else
{
TimeL += 30;
cout
/*Renew->remove();*/
Cashier->dequeue();
} // end else.
} // For if(!Renew->isEmpty)
while (!Registation->isEmpty())
{
TimeR += 60;
temp3 = Registation->peekFront();
cout
cin >> Method;
while (Method != '$' && Method != 'c' && Method != 'C')
{
cout
cout
cin >> Method;
} // end while
Cashier->enqueue(temp3);
if (Method == 'c' || Method == 'C')
{
TimeR += 40;
cout
Checks->enqueue(temp3);
Registation->dequeue();
Cashier->dequeue();
} // end if
else
{
TimeR += 30;
cout
Cashier->dequeue();
Registation->dequeue();
} // end else
} // end while
while (!Checks->isEmpty())
{
temp2 = Checks->peekFront();
cout
Checks->dequeue();
} // end while
if (TotalLicense > 0 && TotalRegistration
{
cout
} // end while
else if (TotalRegistration > 0 && TotalLicense
{
cout
} // end else if
else if (TotalLicense > 0 && TotalRegistration > 0)
{
cout
cout
} // end else if
system("pause");
return 0;
}
OUTPUT
DMV Exercise with Priority Queue implemented. Simulates a Line of people waiting on service How many people arrived? 1 Name: Example What is he here to do? L for Lisence renewal R for automovile Registration L
The people waited in the first Line, this is a 10 sacond wait

template
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
