The following is a implementation of Battleship.