CS 112
Homework 8
Due: Wednesday April 5, 2000
by 12:00 a.m.
List implementation of Stacks
Implement a Stack abstract data type using a linked list (instead
of an array).
- Copy the IntStack.h, IntStack.cpp, bool.h, makefile and test
driver from Hw5.
- Modify what is necessary: the private part in the header file,
the implementation file, and maybe the test driver
(no need to test the stack becoming full, although you can if you wish so.)
References and how to proceed
- You can use the textbook, Chapters 3 and 5, as a reference.
- Create a directory Hw8.
Copy the IntStack.h, IntStack.cpp, makefile and test driver from
Hw5. Modify what is necessary: the private part in the header file,
the implementation file, and maybe the test driver (no need to test the
stack becoming full, although you can if you wish so.)
- Copy the IntList.cpp, IntList.h from lab17. Modify the
Makefile to compile it, too.
- Test the new stack with the same testdriver you used for the
stack implemented as an array.
- Prepare the typescript, then submit ALL the files.
The purpose of this homework is to illustrate code reuse and
the advantages of an object-oriented design of a program, whereas changing
the implementation of a class should not affect the implementation of the
programs which used objects/methods from that class.
To submit
Submit in hw8 all the files: sources, Makefile, a
typescript and a data file with your test data.
See below for naming conventions.
Naming conventions and files to submit (in hw8):
- List of integers: IntList.cpp, IntList.h
- Stack of integers: IntStack.cpp, IntStack.h
- Test driver: testStack.cpp
- Makefile
- Data file: data
- typescript
Extra Credit. Arithmetic expressions again
For this part, you are just going to do arithmetic expressions
(hw6) using this new implementation of the stack.
- Copy the files for the postfix expression you did in Hwk6.
-
Recompile
everything with the new version of the stack.
Submit in hw8E all the header and cpp files, the makefile
and a typescript, with the same naming conventions as in Hw6,
plus the new files for lists (with the same naming conventions as
above).
Ileana Streinu