©2010 Felleisen, Proulx, et. al.

5  Abstracting over Data Definitions, Methods

Portfolio Problems

Work out as complete programs the following exercises from the textbook. Make sure you read the textbook to get a guidance how to proceed.

Problems:

  1. Problem 19.5 on page 271

  2. Problems 19.6 - 19.11 on page 276-279

    You may complete this part with animation using the draw library.

Pair Programming Assignment

Note: Please,use the latest version of tester. It has been posted on February 9, 2010 at 12:32 pm.

5.1  Problem

Design the class CartPt that extends the geometry library class Posn. We will not add any new fields, but by extending the library class we can add new methods to it.

Design the following methods for the class CartPt:

5.2  Problem

The following class diagram describes data definitions that represent a state map:

Each place has a unique name, a location, and a list of neighbors (only their names). The state map is a list of places.

     +-------------+
     | StateMap    |
     +-------------+
     | ILoP places |---+
     +-------------+   |
          +------------+
          |
          v
      +-------+
      | ILoP  |<-----------+
      +-------+            |
          / \              |
          ---              |  
           |               |
     ----------------      |
     |              |      |
 +-------+ +-------------+ |    
 | MtLoP | | ConsLoP     | |
 +-------+ +-------------+ |    
        +--| Place first | |
        |  | ILoP  rest  |-+
        |  +-------------+
        v
   +----------------+
   | Place          |
   +----------------+
   | String name    |
   | CartPt loc     |
   | ILoN neighbors |--+
   +----------------+  |
           +-----------+
           |
           V
       +-------+  
       | ILoN  |<-----------+     
       +-------+            |                     
          / \               |    
          ---               |
           |                |           
    --------------          |        
    |            |          |    
 +-------+ +--------------+ |        
 | MtLoN | | ConsLoN      | |  
 +-------+ +--------------+ |     
           | String first | |              
           | ILoN   rest  |-+               
           +--------------+              

Design the following methods for the classes that represent the state map:

Last modified: Sunday, February 14th, 2010 7:54:40am