Lab DoubleStack - Implement a double stack
The partial source code for this lab is at http://vpl.ccom.uprp.edu.
Suppose that some application requires using two stacks whose elements are of the same type. A storage structure for a two-stack data type could be to use a single array for the storage structure and let the stacks grow toward each other.
Design a class (called DStack
) for this two-stack data type using this implementation and a static array. In your functions for the basic stack operations, the number of the stack to be operated upon, 1 or 2 (or 0/1 as we shall use in our implementation), should be passed as a parameter. Be sure to implement the following:
- the constructor
void push(ElementType e, int stackNum)
void pop(int stackNum)
int top(int stackNum)
: you can assume that the user will only invoke this function after checking that the stack is not empty.bool isEmpty(int stackNum)
bool isFull(int stackNum)
We provide with starter code and a client in the vpl.ccom.uprrp.edu assignment "Stack: Double Stack". All you must do is implement the member functions.
The client implements an interface in which the user enters commands to invoke the various stack functions. For example, when the user types "r 0 22"
the client will insert a 22 in stack #0. See other instructions in the client source code file.
Do not change the client source code since it might damage your results.