©2007 Felleisen, Proulx, et. al.

1  Understanding Data

Portfolio Problems

Pair Programming Assignment

TiVo recordings

All problems in this part become one Beginner ProfessorJ program. Combine all examples of data into one Examples class.

This series of exercises are designed to let you program your Tivo to record the desired TV programs.

1.1  Problem

Develop the data definitions in ProfessorJ Beginner language for the class TimeSlice that represents the information about the starting and ending time of a TV show (just the time of day - ignore the date of the show). For simplicity assume that every show starts and ends on the same day (No Comedy Central - sorry). Include a class diagram.

Hint: See if the class ClockTime from the portfolio problems can be useful. Solution

1.2  Problem

Develop the data definitions in ProfessorJ Beginner language for the class ShowTime that records the information about the time of the show you want to record. Your TiVo recorder needs to know the date, the starting time, and the time to stop recording. Include a class diagram.

Is the solution to the previous problem useful here? Solution

1.3  Problem

Develop the data definitions in ProfessorJ Beginner language for the information about TV shows. For every show you need to know the name of the show, the channel on which to record the show, and the time when to record (see the previous problem). Include a class diagram. Name your class TVshowSolution

Note: It is sufficient to include the last class diagram in the program you hand in. However, we strongly suggest that you draw the diagrams as you design each new class.

City Map

1.4  Problem

Translate the class diagram in figure 1.4 into a class definition. Also create instances of the class. Include among your examples the data that represents the locations on the enclosed map (figure 1.4). The grid lines are 20 pixels apart. Solution


                     +---------------+                     
                     | InterestPoint |                     
                     +---------------+                     
                     +---------------+                     
                             |                             
                            / \                            
                            ---                            
                             |                             
         ----------------------------------------          
         |                   |                  |          
  +--------------+    +-------------+    +--------------+  
  | Hotel        |    | Museum      |    | Hospital     |  
  +--------------+    +-------------+    +--------------+  
  | String name  |    | String name |    | String name  |  
+-| Place loc    |  +-| Place loc   |  +-| Place loc    |    
| | String phone |  | | String kind |  | | boolean er   |  
| +--------------+  | | String url  |  | +--------------+  
|                   | +-------------+  |   
|    +--------------+                  |
+--+ | +-------------------------------+                    
   | | |                                                      
   v v v
+-------+
| Place |
+-------+
| int x |
| int y |
+-------+

Figure: A class diagram for city map points of interest

[ex1-Z-G-1.gif]

Hotel California
Hotel Baltimore
Museum of Fine Arts
Paul Revere House
Mercy Hospital
Lazarus Hospital

Figure: A sample city map


Morphing a Polygon

1.5  Problem

Convert the data definitions for the polygon from the previous assignment into Java. Every data definition in Scheme should translate into a class definition in Java. Use your examples from the previous assignments as examples for this exercise. Solution

Last modified: Friday, September 14th, 2007 3:11:22pm