CIS 350 Assignment 1
Fall 2000
For your first assignment you will have the opportunity to
explore object-oriented programming as a means of implementing
stacks and queues. In simulations, waiting lists are implemented
using either a LIFO or FIFO policies. Your task will be to write
a client program that allows the user to determine at run-time
whether a given item in a 6 element array is to be managed using
a LIFO or FIFO policy for simulation purposes.
Under a LIFO policy new items are pushed onto a stack and
are removed by popping items off the stack. Under a FIFO policy
new items are enqueued and dequeued from a queue. To allow the
user to determine a run-time that policy will be used for a given
item, you will need to declare stack and queue objects as
descendants from a common ancestor. The ancestor type (or base
class) will also serve as the basis to declaring the array
element type.
Your programming task is to implement a stack class, a queue
class, a common ancestor class, and an array class. You will then
need to write a client program that demonstrates the degree to
which your stack and queue objects can be used interchangeably.
For example, you might define a procedure, which display the
contents of the stack or queue passed as its input parameter. You
also should devise experiments which demonstrate the weaknesses
of your implementations (e.g. "extra" method calls which are not
part of the stack ADT specification). Your output must display
information with sufficient detail to make it possible for me to
trace the execution of your program.
You may do your work on Unix or on a PC. You may write your
programs using C++ or Java. Your solution must involve the
implementation of the stack, queue, and array ADT's as object
classes descended from a common ancestor (perhaps some list or
table type). As mentioned in class, the only operations allowed
on instances of stacks or queues, are the methods defined for
their classes (i.e. type cheating is not allowed). Your ADT's
must be implemented in using C++ classes or their equivalent. Do
not forget what you were taught about structured programming and
top-down modular design (and testing) in CIS 200.
You will need to turn in a properly commented source listing
of your problem solution, which includes the messages generated
by the compiler. You will also need to turn in the sample run,
along with a 3 to 5 page memo describing your solution with
emphasis on the data structures used and a discussion of the
efficiency of your solution (including relevant "big-Oh" type
information).
Assigned: 9-19-00
Due date: 10-10-00