Battleship Game 2

I was wondering how you would go about placing different size ships in an array to play the game with. I need to be able to also keep track of the number of hits on each different ship. My biggest question is how to place a 7 ships: one of size 5, one of size 4, one of size 3, one of size 2, and three of size 1.

I have a currently working program that can place several size one ships; but I don't know how to make it work with ships of different sizes.

Thank you!
you have a board here and you will have ships inside that infact multiple ships
something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
class ship
{
int x;
int y;
int length; x,y + length can help in finding the exact location of the ship
int direction;//it can be horizontal or vertical
};

class board
{
vector<ship>;//remove the ship from vector if its fully hit, on each hit update hits data
bool hits[][];//keep track of hits, coordinate if true means that is already hit.
};


on each hit update the data and ask each ship if its fully hit, if yes then remove it from vector.
as soon the vector is finished the game ends.
i dont know if this idea fits into your requirements. obviously, it will need further improvements and some more additions of data structures.
Topic archived. No new replies allowed.