Exercise Set 5: Interfaces

Exercise 5.1 The given UML diagram describes classes that define a list of measurable objects with a sample method totalSize and a sample class MString on which the list is tested.

Exercise 5.2 The Java Comparable interface is designed to support uniform comparison of objects.

Exercise 5.3 Develop further tests and uses of the list of Comparable objects from the previous exercise. Develop the class CompRectangle which extends the Java class Rectangle by implementing the Comparable interface. The comparison is based on the area of the rectangle. Test the class CompList using the class CompRectangle. Draw the UML diagram of this collection of classes.