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* slistPtr; // Pointer to sorted list of

// 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::SL_PriorityQueue()

{

} // end add

template

SL_PriorityQueue::SL_PriorityQueue(const SL_PriorityQueue& pq)

: slistPtr(new LinkedSortedList(*pq.slistPtr))

{

} // end add

template

SL_PriorityQueue::~SL_PriorityQueue()

{

delete slistPtr;

}

template

bool SL_PriorityQueue::isEmpty()const

{

return (slistPtr->isEmpty());

}

template

ItemType SL_PriorityQueue::peek()const throw(PrecondViolatedExcep)

{

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::add(const ItemType& newEntry)

{

slistPtr->insertSorted(newEntry);

return true;

} // end add

template

bool SL_PriorityQueue::remove()

{

// 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*Renew = new SL_PriorityQueue();

LinkedQueue*SignIn = new LinkedQueue();

LinkedQueue*Cashier = new LinkedQueue();

LinkedQueue*Registation = new LinkedQueue();

LinkedQueue* Checks = new 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

I have this code. After entering some inputs it breaks. The picture

template::add (const ItemType& newEntry) 60 61 62 63 64 65 slistPtr-insertSorted (newEnt return true: // end add templateclass ItemTypex 67 68 69 70 71 72 73 74 75 bool SL_PriorityQueue: :re :II The highest priority item is ) // end remove Exception Thrown Exception thrown: read access violation. this->slistPtr was nullptr eturn sli stPtr->remove(slistPtri #endif Copy Details 4 Exception Settings VI Break when this exception type is thrown Except when thrown from MVD simulation.exe als ame Open Exception Settings Edit Conditions this newEntry "Example template::add (const ItemType& newEntry) 60 61 62 63 64 65 slistPtr-insertSorted (newEnt return true: // end add templateclass ItemTypex 67 68 69 70 71 72 73 74 75 bool SL_PriorityQueue: :re :II The highest priority item is ) // end remove Exception Thrown Exception thrown: read access violation. this->slistPtr was nullptr eturn sli stPtr->remove(slistPtri #endif Copy Details 4 Exception Settings VI Break when this exception type is thrown Except when thrown from MVD simulation.exe als ame Open Exception Settings Edit Conditions this newEntry "Example

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!