Design and implement a MultipleStack class
which provides
stacks in a single container.
The declaration of the class should look something like this:
class MultipleStack(Container):
def __init__(self, numberOfStacks): ...
def push(self, obj, whichStack): ...
def pop(self, whichStack): ...
# ...
-
In addition to self,
the __init__ method takes a single integer argument
that specifies the number of stacks in the container.
-
In addition to self,
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.
-
In addition to self,
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.