This website is preserved for historical and scholarly reference and is no longer actively maintained.
CpSc 241, Section 1
Assignment 5
16 February 2000
Due: Wednesday, February 23 at midnight
Late penalties: 20 points per partial day late. That is, programs
turned in after midnight Wednesday and before midnight Thursday
will have 20 points deducted for late, programs turned in after
midnight Thursday and before midnight Friday will have a total
of 40 points deducted for late, etc.
Total point value of assignment: 100 points
Late submissions not accepted after: Saturday, February 26 at midnight
This assignment is to be done INDIVIDUALLY.
Create a directory, A5, which will contain all parts of this assignment.
You will need class ListNode, class ListItr, and class List from the text.
You will also need
a5.cpp (your main program)
The objectives of this program are to give you more experience with
program design and with traversing a list.
The main() will be called a5.cc or a5.cpp, whichever you choose. Submit
all files in directory A5 using handin.
Part I: You are to design a method, retreat(), which is to be part
of the ListItr class. When you design this method, you will
discover a reason why you cannot simply insert the retreat
method in the class. Hint: Try drawing a picture of a List
with a ListItr referencing some node half-way down the List.
After you have written your code, trace the action of your
code on the List. Why does it not work?
If itr is an object of type ListItr, a call to retreat will
look like
itr.retreat( );
If you can't figure out why the code will not work by tracing
with paper and pencil, your last resort will be to type in the
code and let the system tell you why it won't work -- maybe.
After you figure out why your code won't work, email your
instructor and tell her why it won't work. Also suggest what
you could do to the ListItr class so that retreat would work.
Do not change either the List class or the ListNode class.
********** Part I MUST BE COMPLETED BY MONDAY NIGHT **********
Part II: Write a main program called a5.cpp that thoroughly tests
the retreat code.
Other requirements:
Follow the style standards to be found from your instructor's
web page for CPSC 241.
Grading rubric:
Maximum of 10 points (out of 100) awarded for retreat in List class.
Part I: 30 points. Must be before deadline.
Style standards, including required documentation 20 pts.
Program compiles without errors. 10 pts.
If the the program does not compile without error, no further points
will be awarded.
Logically correct choice for retreat past beginning of List 10 pts.
Retreat works correctly for some, but not all, situations 10 pts.
Retreat works all the time 30 points.