Implemented printGrid and isValidPoint function