CS 2010 Homework 13   - Due November 25

Setup

profj3.plt
Install the newest ProfessorJ update in a special way. To install:
  1. Quit DrScheme
  2. Start Help Desk as a separate program
    • Windows: Help Desk should be next to DrScheme in the Start menu
    • Unix: run the program help-desk
    • Mac OS: Help Desk should be next to DrScheme in the PLT folder
  3. Select Open URL... in Help Desk's File menu
  4. Click Browse
  5. Select the profj.plt file that you downloaded
  6. Click Ok in the "Open URL" dialog
  7. When asked, click Download & Install (it uses the file instead of downloading)
  8. Quit Help Desk and start DrScheme
Unfortunately, installing the patch from within DrScheme will not work.

Assignment

Exercise 13.1, Swimmers

A Swimmer is either

Implement classes for all three kinds of swimmers, and group them under suitable abstract classes. Put the constructor arguments in the above orders. Note that all swimmers have a length.

Exercise 13.2, Lists of Swimmers

Implement a List datatype to represent a collection of Swimmers. The datatype should include Empty and Cons variants.

Exercise 13.3, Long Swimmers

Implement a longer method of List that takes a number and returns a list of all of the Swimmers in the original list that are longer than the given number.

You may need to add new methods to one or more other classes, but avoid redundant code where possible.

Exercise 13.4, Sleek Swimmers

Implement a sleek method of List that returns a list of all of the Swimmers in the original list that are longer than 5, not including any turtles that are older than 31.

You will need to add new methods to some other classes, but avoid redundant code where possible.

Exercise 13.5, Swimmers with Gills

Implement a gills method of List that returns a list of all of the Fish in the original list.

You will need to add new methods to some other classes, but avoid redundant code where possible.

Exercise 13.6, Dangerous Fish

Add a new kind of Fish to the variants of Swimmer:

Note that anything that's true of all fish will be true of a Piranha.

Exercise 13.7, Deadly Swimmers

Implement a deadly method of List that returns a list of all of the Piranhas and Crocodiles in the original list.

Again, you will need to add new methods to other classes.

Exercise 13.8, Deadly Bites

Implement a oneBite method of List that works when the list contains only Piranhas and Crocodiles. The oneBite method takes a number and returns true if all of the swimmers in this list have a maximum bite size at least as large as the number.

To implement this method, you will need to add an interface to your program and change some existing classes to implement the interface.


Last update: Friday, November 21st, 2003
mflatt@cs.utah.edu