Develop and implement a game of Battleship that pits a human player against a computer opponent.
You may work in pairs on this project if you wish. Both people in each pair must email me to confirm that you are working together.
The program should display the following items:
The program should begin by initializing (of course) and then reading the positions of the boats. Use arrow keys to position a boat, press Enter to lock in the boat's position, then arrow keys again to choose a direction and finally Enter to finalize the boat's location. Do not allow boats to hang over the edge of the board, and do not allow boats to overlap other boats.
Once the boats are placed, place the computer boats randomly, obeying the two restrictions given in the previous paragraph.
Choose who starts at random.
For the user's turn, have them choose a cell by coordinates A-J, 0-9. Upper or lower case should be treated the same. Give the user the appropriate result:
The computer should choose randomly and automatically process its choice.
Do not let either player select the same cell twice.
End the game if the user chooses 'q' (or 'Q') at any time.
If either player's fleet is sunk, end the game with an appropriate message