Design and implement a MultipleStack class
which provides stacks in a single container.
The declaration of the class should look something like this:
public class MultipleStack
implements Container
{
public MultipleStack (int numberOfStacks);
public void push (Object object, int whichStack);
public Object pop (int whichStack);
// ...
};
-
The constructor takes a single integer argument
that specifies the number of stacks in the container.
-
The push method takes two arguments.
The first gives the object to be pushed
and the second specifies the stack on which to push it.
-
The pop method takes a single integer argument
which specifies the stack to pop.
Choose one of the following implementation approaches:
-
Keep all the stack elements in a single array.
-
Use an array of Stack objects.
-
Use a linked list of Stack objects.