A stamp has a descriptive name, a face value, and an issuing country. Stamps have a measurable value (the face value), hence it makes sense for the Stamp
class to implement the Measurable
interface from Chapter 9. You can also compare two stamps to find which has higher value, so it makes sense to implement the Comparable
interface from the standard Java library as well.
In fact, any two measurable objects can be compared, simply by comparing their measures. We can implement the compareTo
method of the Comparable
interface in a class AbstractMeasurable
that implements both the Comparable
and Measurable
interfaces. Then the Stamp
class simply extends that class.