complete assignment 2

1. complete the code.
2. add comments.