CS 635 Advanced Object-Oriented Design & Programming

Spring Semester, 2006

Assignment 2

Assignment Index

© 2006, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 2/15/06

Assignment 2

Due Feb 21, 2006

Modified Feb 15 (See part 6)

The goal of this assignment it so implement the null  object, iterator and visitor patterns. The pattern are a bit of over kill for the situation we are using.

  1. Implement a doubly linked with null objects at the beginning and end of the list. So an empty list will contain two null objects. The linked list contain integers.

  1. Implement method(s) to add new items at the front of the list. Implement method(s) to add new items at the end of the list.

  1. Implement a method to determine if an item is in the linked list. This method is to return true if the item is in the list, and false if the item is not in the list. This method is to do its work by sending a message to null node in the front of the list. The nodes will pass the message on to the next node if needed. (Some people call this a recursive implementation.)

  1. Implement an iterator to iterate over the linked list from front to back. The goal is to implement an iterator not just use an existing iterator, so don't convert your list to an existing collection to use its iterator.

  1. Implement a visitor to visit from front to back an instance of your linked list and produce a list of all the odd valued elements in the list. Be careful here. The structure here is so simple it is easy to simply one's code so that it is not an implementation of the visitor pattern.

  1. ( Added Feb 15 ) Implement a visitor that constructs a string representation of the numbers in the linked list. The representation starts with and "( " is followed by the integers in the linked which are separated by a " - " and ends with " )". So an empty list results in "( )". A list with one integer 42 results in "( 42 )", a list with the integers (in order from front to back of the list) 5, 42, 3 results in "( 5 - 42 - 3 )". The quotes in the above are just there to denote in the text the start and end of special tokens and are not intended to be part of the programs output.  

  1. Write unit test for the functionality above.

You are to write your own linked-list code.

Language

The prerequisites for CS636 are CS535 and knowing C++, Java, C#, Ruby or Smalltalk. Your assignment must be in one of these languages.

Grading

 

Percent of Grade

Working Code

15%

Unit Tests

15%

Quality of Code

20%

Proper implementation of Patterns

50%

What to Turn in

Turn in hard copy of your code.

Note to C++ people. C++ classes are have a header and an implementation. Place the header  and implementation in separate files. Do not include any implementation in the header file.

Late Policy

An assignment turned in 1-7 days late, will lose 3% of the total value of the assignment per day late. The eight day late the penalty will be 40% of the assignment, the ninth day late the penalty will be 60%, after the ninth day late the penalty will be 90%. Once a solution to an assignment has been posted or discussed in class, the assignment will no longer be accepted. Late penalties are always rounded up to the next integer value.