CS 635 Advanced Object-Oriented Design & Programming

Spring Semester, 2006

Assignment 4

Assignment Index

© 2006, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 4/23/06

Undo

Due May 9

The goal of this assignment is to study the patterns that are related to undo.

We will use the operations add first, add last, remove nth and reverse on ordered collections. The actual type of collection you use will depend on the language you are using: OrderedCollection in Smalltalk, ArrayList in Java, Array in Ruby and the equivalent in C++.

Create a program that contains two menus: “Collections” and “Edit”.

Collections Menu

The “ Collections ” menu will manage a group of collections. The “ Collections ” menu will have the following menu items: “New”, “Make Active…” and “Print”.

The “New” menu item will create a new empty collection and make it the active collection. When a new collection is created, it is given a creation number that does not change.

The “Make Active…” menu item will prompt the user for a number between 1 and N, where N is the current number of collections created with the “New” menu item. The number given by the user indicates the creation number of the collection to make active.

The “Print” menu item will print (display) the contents of the active collection on an output device of your choice. This will make it easier for you to determine if your program is working.

Edit Menu

The “Edit” menu is used to modify the contents of the active collection. This menu has the items: “Add Last…”, “Add First..”, “Remove...”, “Reverse”, “Undo” and “Redo”. All these operate on the collection that is currently active.

The “Add Last…” menu item prompts the user for a string. This string is added at the end of the collection. Note this means that this is a collection of strings, not one string.

The “Add First…” menu item prompts the user for a string. This string is added at the front of the collection.  

The “Remove …” menu item prompts the user for a number. This number is the index of the item in the active collection to remove.

The “Reverse” menu item reverses the order of the elements in the active collection.

The “Undo” menu item undoes the last edit operation done on the active collection. This can be repeated to undo all the edit operations done on the active collection. One cannot undo the creation of a collection. The “Undo” menu item does not change any collection that is not active. One could create collection 1, perform edits on the collection, create collection 2, perform edits on the second collection, make the first collection active, and perform some more edits on the first collection. Repeated use of the “Undo” would undo all the edits of the first collection (which is currently active) and not change the second collection.

The “Redo” menu item redoes the last action that was undone on the active collection. This can be repeated to redo all the undone operations on the active collection. When one performs a new action from the menu, the redo buffer on the active collection is flushed.

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.