My professor wants to me to create a battleship program that has a grid of 15x15. The battleship program should have five boats in the game:
Frigate: 2 locations
Tender: 2 locations
Destroyer: 3 locations
Cruiser: 3 locations
Carrier: 4 locations
-The ships cannot overlap or be located outside of the board.
-It should allow the user to enter a location.
-The program should display hit or miss..
-The board should display the location the user hit and occupied.
-After the user has sunk the ship, a message should display which ship has been sunk.
-The user gets 60 tries.
- Check if random coordinates on placeShips() don't place ships inside other or outside the grid.
- Write a function that prompts the player for a coordinate.
- Create a variable that indicates the current player. Put the function above inside a loop and change it so that it asks each player in turn.
- Create a function that takes a coordinate as a parameter and checks that position is occupied.
- Change the function above to only check for ships that are enemies of the current player.
Remember that dividing the development in incremental phases like this makes it programming much easier.
use a 2d array and set every spot on the grid to 0, next just come up with ids for each ship and when a ship is placed the squares it takes up are changed to the ship id.