# Portfolio Problems

• Classes of Data: Exercises 2.2 and 2.3, page 16 in HtDC

• Classes of Data with Containment: Exercises 3.2 and 3.3, page 26 in HtDC

• Classes of Data with Containment that we will need: The textbook introduces the classes of data to represent the clock time and the date. Copy the definitions, in the ProfessorJ Beginner language. Include examples of data and the class diagrams.

Note: Use this solution in your main programming assignment.

• Unions of Classes of Data: Exercises 4.5 and 4.6, page 35 in HtDC

• Unions of Classes of Data with Contaiment (Self-Referential Data):

Start by defining all the classes needed to implement the runner’s log (i.e. `ILog` interface and the classes needed to imnplement it) from the textbook.

Now, do exercises 5.1 and 5.2 on pages 41 and 42 in HtDC

# 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 `TVshow`Solution

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.

## 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

 Figure: A sample city map

## 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