/* Lecture: January 20, John Clements

Today I showed how to write methods for unions.

I did this by going through an entire example in scheme, and then translating it into Java.

The example:

(define-struct run (time speed))
(define-struct row (time pace))
(define-struct weights (reps weight))
; a Workout is one of
;  - (make-run number number)
;  - (make-row number number)
;  - (make-weights number number)

Now define the function 'calories-burned':

; compute the calories burned by a workout
; calories-burned : workout -> number

Develop the thing in scheme, using the complete design recipe

Next, I asked the students to write down the class diagram corresponding in our UML-like language.

Together, we defined the classes (including purposes for each) in Java.

Next, we defined an examples class that created examples of each kind of data (examples 
taken from Scheme).

We stopped to observe that we had completed step one in the design recipe.  What comes next? 
Ah, contract & purpose for caloriesBurned.

But... where should it go?  We had a nice discussion about why it should appear 
in the abstract base class, and what it means to define a class in the abstract base class.

We saw how the scheme function had the contract : workout -> number, and discussed why (in Java) 
the first argument is implicit;  we don't need to say that we accept a workout, because 
that's what "this" does.

We then translated examples of the function from Scheme into Java.

Then, we went over the template; each clause in the scheme template corresponds to a method 
definition in a Java sub-class. We don't need predicates, because Java's dispatch mechanism 
takes care of this for us.  We do need selectors, though:  this.time, this.speed, etc.

Finally, we defined the methods in each class and tested them.

*/
