Refactored main() function: added init(), checkWin() & checkLose()

Fixes issue #1.