©2006 Felleisen, Proulx, et. al.

1  Understanding Data

Etudes

Work out the problems 4.4, 4.5, 4.6, and 4.7 in the textbook.

Main Assignment -- Part 1

All problems in this part become one Beginner ProfessorJ program and one Beginner HtDP program. In ProfessorJ 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

The textbook introduces the classes of data to represent the clock time and the date. Copy the definitions, both in the Beginner HtDP Language and in the ProfessorJ Beginner language. Include examples of data and the class diagrams. Solution

1.2  Problem

Develop the data definitions - both in the Beginner HtDP Language and in ProfessorJ Beginner language for the information about the starting and ending time of a TV show. In Java, name your class TimeSlice. For simplicity assume that every show starts and ends on the same day (No Comedy Central - sorry). Include a class diagram. Solution

1.3  Problem

Develop the data definitions - both in the Beginner HtDP Language and in ProfessorJ Beginner language for the information about the time of the show you want to record - the date and the time interval. Include a class diagram. In Java, name your class ShowTimeSolution

1.4  Problem

Develop the data definitions - both in the Beginner HtDP Language and 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. Include a class diagram. In Java, 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.

Main Assignment -- Part 2

1.1  Problem

Translate the class diagram in figure 1.1 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.2). 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 1.1: A class diagram for city map points of interest

[city.tiff]

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

Figure1.2: A sample city map

Last modified: Tuesday, September 5th, 2006 10:12:34am