Add example code chapter2-2 and chapter2-3.

This completes the code from Chapter 2.