©2010 Felleisen, Proulx, et. al.

5  Equality, Constructors, Extending Classes

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

5.1  Problem

Complete the work on Problem 5.2 from Lab 5 and hand in your solution.

5.2  Problem

Complete the work on Problem 5.3 from Lab 5 and hand in your solution.

5.3  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.4  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: Wednesday, October 6th, 2010 4:31:18pm