Section 2.1.1 - Example: Arithmetic Operations for Rational Numbers

Exercise 2.1

Section 2.1.2 - Abstraction Barriers

Exercise 2.2

Exercise 2.3

We assume that the rectangle’s height and width are parallel to the x and y axes
to simplify computations. We can define the procedures that calcualte area and
perimeter as:

Note that these depend only on the rect-width and rect-height selectors. Now
we can create a rectangle representation based on its two opposing points:

And another representation based on its diagonal. Note that we do not change any
of the interfaces, just the underlying implementation: