©2005 Felleisen, Proulx, et. al.

1  Understanding Data

Simple classes

1.1  Problem (2.1.1)

Translate the three examples of information from the GPS problem into instances of GPSLocation.

Copy the class definitions from the textbook and show the examples as data in the Examples class.

What is the meaning of new GPSLocation(50.288,0.11) in this context? Include your answer as a block comment in the file that holds the rest of the problem answers.

1.2  Problem (2.1.2)

Take a look at this problem statement:

Develop a program that assists a bookstore manager. The program should keep a record for each book. The record must include its book, the author's name, its price, and its publication year.
Develop an appropriate class diagram and implement it with a class. Create instances of the class to represent these three books:
  1. Daniel Defoe, Robinson Crusoe, $15.50, 1719;

  2. Joseph Conrad, Heart of Darkness, $12.80, 1902;

  3. Pat Conroy, Beach Music, $9.50, 1996


+-------------------------+
| Auto                    |
+-------------------------+
| String model            |
| int price /* dollars */ |
| double mileage          |
| boolean used            |
+-------------------------+

Figure 1: A class diagram for automobiles

1.3  Problem (2.1.4)

Translate the class diagram in figure 1 into a class definition. Also create instances of the class.

Last modified: Monday, January 10th, 2005
HTML conversion by TeX2page 2004-09-11