Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#ifndef H_QueueType #define H_QueueType #include <iostream> #include <cassert> #

ID: 3559625 • Letter: #

Question

#ifndef H_QueueType
#define H_QueueType

#include <iostream>
#include <cassert>
#include <string>

using namespace std;

// definition of the template class queueType
template <class Type>
class queueType
{
   public:
       // data methods of the class
       const queueType<Type>& operator=
                                   (const queueType<Type> &);
       queueType(const queueType<Type>& otherQueue);

       bool isEmptyQueue() const;
       bool isFullQueue() const;
       void initializeQueue();
       Type front() const;
       Type back() const;
       void addQueue(const Type&);
       void deleteQueue() ;
       queueType<Type>(int queueSize = 100);

       void moveNthFront ( int n );
       void print();
   private :
       // data members of the class
       int maxQueuesize;
       int count;
       int queueFront;
       int queueRear;
       Type *list;

       // member function
       void copyQueue ( const queueType<Type>& );
}; // end template class queueType

template <class Type>
void queueType<Type>::moveNthFront(int n)
{
   // check for valid n
   if ( n <= 1 )
   {
       cout << " lnvalid. ";
       return;
   } // endif

   // store the Nth element in a temporary variable
   Type temp = * ( list + n - 1);

   // move the ele

Explanation / Answer

001 #ifndef H_queueType 002 #define H_queueType 003 004 #include 005 #include 006 007 using namespace std; 008 009 template 010 class queueType // public queueADT 011 { 012       public: 013              const queueType& operator=(const queueType&); 014              bool isEmptyQueue() const; 015              bool isFullQueue() const; 016              void initializeQueue(); 017              Type front() const; 018              Type back() const; 019              void addQueue(const Type& queueElement); 020              void deleteQueue(); 021              queueType(int queueSize = 100); 022              queueType(const queueType& otherQueue); 023              ~queueType(); 024              void printQueue(); 025              bool operator== (const queueType&); 026              bool operator!= (const queueType&); 027                028       private: 029               int maxQueueSize; 030               int count; 031               int queueFront; 032               int queueRear; 033               Type *list; 034               bool isEqual(const queueType&); 035 }; 036 037 template 038 bool queueType::isEmptyQueue() const 039 { 040      return (count == 0); 041 } 042 043 template 044 bool queueType::isFullQueue() const 045 { 046      return (count == maxQueueSize); 047 } 048 049 template 050 void queueType::initializeQueue() 051 { 052      queueFront = 0; 053      queueRear = maxQueueSize - 1; 054      count = 0; 055 } 056 057 template 058 Type queueType::front() const 059 { 060      assert(!isEmptyQueue()); 061      return list[queueFront]; 062 } 063 064 template 065 Type queueType::back() const 066 { 067      assert(!isEmptyQueue()); 068      return list[queueRear]; 069 } 070 071 template 072 void queueType::addQueue(const Type& newElement) 073 { 074      if (!isFullQueue()) 075      { 076        queueRear = (queueRear + 1) % maxQueueSize; 077          078        count++; 079        list[queueRear] = newElement; 080      } 081        082      else 083        cout