Question
using c++ i need the implemntation of each function please // QueueLinked.h #include #include using namespace std; #include Queue.h template class QueueLinked : public Queue
using c++ i need the implemntation of each function please
// QueueLinked.h
#include
using namespace std;
#include "Queue.h"
template
void enqueue(const DataType& newDataItem) throw (logic_error); DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const; bool isFull() const;
// Programming Exercise 2 void putFront(const DataType& newDataItem) throw (logic_error); DataType getRear() throw (logic_error); // Programming Exercise 3 int getLength() const;
void showStructure() const;
private: class QueueNode { public: QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem; QueueNode* next; };
QueueNode* front; QueueNode* back; };
//-------------------------------------------------------------------- // // Laboratory 7, Programming Exercise 1 storesim.cs // // Program implementation shell. // //--------------------------------------------------------------------
// Simulates the flow of customers through a line in a store.
#include
// Use which ever implementation is currently configured. #if LAB7_TEST1 # include "QueueLinked.cpp" #else # include "QueueArray.cpp" #endif
using namespace std;
int main () { #if LAB7_TEST1 QueueLinked
// Seed the random number generator. Equally instructive to run the // simulation with the generator seeded and not seeded. srand( time(NULL) );
cout << endl << "Enter the length of time to run the simulator : "; cin >> simLength;
// Put your code here to run this simulation. Use "rand()" to get // a pseudorandom number that you can use to calculate probabilities.
// Print out simulation results cout << endl; cout << "Customers served : " << totalServed << endl; cout << "Average wait : " << setprecision(2) << double(totalWait)/totalServed << endl; cout << "Longest wait : " << maxWait << endl;
return 0; } //-------------------------------------------------------------------- // // Laboratory 7 Queue.h // // Class declaration of the abstract class interface to be used as // the basis for implementations of the Queue ADT. // //--------------------------------------------------------------------
#ifndef QUEUE_H #define QUEUE_H
#include
using namespace std;
//--------------------------------------------------------------------
template
virtual ~Queue();
virtual void enqueue(const DataType& newDataItem) throw (logic_error) = 0; virtual DataType dequeue() throw (logic_error) = 0;
virtual void clear() = 0;
virtual bool isEmpty() const = 0; virtual bool isFull() const = 0;
// The conditional compilation tests below are very important. // Because the functions declared are pure virtual functions, if they // are declared in the base class, then they MUST be implemented in any // derived classes. But they are supposed to be optional implementations. // Consequently, they must only be declared here if they are being // implemented in the derived classes. #if LAB7_TEST2 virtual void putFront(const DataType& newDataItem) throw (logic_error) = 0; virtual DataType getRear() throw (logic_error) = 0; #endif #if LAB7_TEST3 virtual int getLength() const = 0; #endif
virtual void showStructure() const = 0; };
template
#endif // #ifndef QUEUE_H
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started