// queuedr.cpp

// Creates a templated queue.  Implementation is with dynamically
// allocated array whose size is argument to ctor.
// Experiment with this: fill the queue, try to add eleventh item,
//remove some items, add some more (the array is acting as a wrap-
//around array, or circular buffer), delete all...  
//Ex. If you add 10 items, delete 3, then add two more, the front item 
//is at array element 3, the rear item is at element 1. 


#include <iostream>
#include "QueType.h"

using namespace std;

int main() {

  QueType<int> Q1(10);  //queue of ints.  max # of entries is 10
  char cmd;
  int num, qnum;

  cout << "Enter commands to enqueue (e) or dequeue (d).  e followed by"
       << " number.  q to quit" << endl;
  cout << "Example: e 23  e 6  d  e7 q" << endl << endl;
  Q1.View();

  do {
    cin >> cmd;

    if (cmd == 'e') {     //Enqueue command
      cin >> num;
      if (!Q1.IsFull()) {     //queue is not full
	Q1.Enqueue(num);      //put the item to the rear of the queue
        cout << num << " added to queue" << endl;
      }
      else
        cout << "queue is full!  item not added." << endl;
    }
    else if (cmd == 'd') 
      if (!Q1.IsEmpty()) {   //queue is not empty
        Q1.Dequeue(qnum);    //get the item at front of queue
        cout << qnum << " removed from queue" << endl;
      }
      else
        cout << "queue is empty.  nothing to dequeue" << endl;
    
    Q1.View();

  } while (cmd != 'q');
}



  
