Array Stack and Queue

For this first assignment you will be writing simple array based stacks and queues. Your classes should be templated and they should inherit from the following virtual base classes. My code will only call methods that are part of these base classes. Note that for templated classes, the methods have to be put in the header files, not in a separate source file. Your classes should be called ArrayStack and ArrayQueue and they should be in files called ArrayStack.h and ArrayQueue.h.

template<typename T>

class Stack {

public:

virtual ~Stack() {}

virtual void push(const T &t) = 0;

virtual T pop() = 0;

virtual T peek() const = 0;

virtual bool isEmpty() const = 0;

};

template<typename T>

class Queue {

public:

virtual ~Queue() {}

virtual void enqueue(const T &t) = 0;

virtual T dequeue() = 0;

virtual T peek() const = 0;

virtual bool isEmpty() const = 0;

};

Make sure that your classes have appropriate copy constructors and assignment operators. These can work with the ArrayStack and ArrayQueue types and not the supertypes to keep things simple for you. For performance reasons you might consider implementing a move methods, but that isn't required to pass the test code. You are not allowed to use any of the standard collections for this assignment. So no vector, deque, list, etc.

You will lose 30 points if you do not free memory appropriately.

You should put these classes in proper header files called Stack.h and Queue.h. You will not need to submit those. Only submit ArrayStack.h and ArrayQueue.h. You will not submit your test code either, but you will be asked to show it during the code review in order to get those points. For this assignment you can put your test code in a main and not in unit tests.

Test Rubric:

Basic tests of all methods (10 points)

Large tests (1000+ items) (5 points)

Tests with multiple types, including non-primitives (5 points)