Implemented Assignment2 required task: 2, 3, 4.
Need to do code refactor.
Refine codes.