added all game running code into a class and methods