Finish exercises in Chapter 8
Merge pull request #10 from gs3/chapter-8-exercises

Refactor some codes.