Use these classes not only to learn about interfaces but
to begin seeing how large systems are written.

Put these classes into a new project in Eclipse in order to study
these classes.

1. Take a look at class Circle.
Study its functions equals and toString. Note
how both of them call the same function but in the superclass,
using "super.".

Note how all three functions have the @Override annotation.
This helps prevent errors . For example, if a function name were
misspelled, it would not override the function in the superclass
and an error would be signaled --wouldn't happen without @Overrid.


2. Class Shape is the big one. Here are things to consider:

2A. Study function equals. Note how it implements the specification.

2B. Function area is abstract, so every subclass must override it.

2C. Look at the loop in sumAreas. Because function area is declared
in Shape, the call s[i].area() is legal. But at runtime, the
overriding method (in Circle, Rectangle, or other subclass) will
be called.

2D. Look at how toString produces a String in a nice format for
points in the plane.

2E. Function compareTo is there! We happen to
return -1, 0, or 1, but it could be any negative or positive.
One reason for this. Suppose area() returned an int instead of
a double. Then we could write this method simply as

     return area() - s.area();
     
2F. Look at static function toString(Shape[]. In the expression

     res + s[k]
     
Java will automatically call s[k].toString() here, so this is
equivalent to
  
     res + s[k].toString 
     
2G. Run the program. YOu will see good output. The call on
sort in line 45 (procedure main) really worked!

Now comment out the implements clause,

     implements Comparable<Shape>
     
on line 4 and run again. You get an error at runTime.

2H. Hover your mouse over the word sort on line 45. A window
opens that gives you the specification of that method. It tells
you that the "natural ordering" is used --all array elements must
implement interface Comparable, and its method compareTo is
called when sorting to indicate which of 2 array elements are
"smaller".


2H. Look at the overall structure of class Shape! Lots of methods,
but all very short! This is typical of OO programming.