Exercises 10-12 on http://www.greenteapress.com/thinkapjava/html/thinkjava010.html#toc80