I need to finish this program, but i have no idea how to! please help me figure this out.

#include <iostream>
#include <fstream>
using namespace std;

void printShips(char [15][15]);
void fire(int row, int col, char ocean[15][15], char &result, char &ship);
struct counter
{
	int B, C, D, F, T, S;
};

int main()
{
	ifstream myin;
	char ocean[15][15];
	char battle[15][15];
	int i,j;
	char trash;
	int missles = 30;
	bool won = false;
	int row, col;
	char result, ship;
	counter counters;

	//Initialize the counters
	counters.B = 4;
	counters.C = 5;
	counters.D = 3;
	counters.F = 2;
	counters.S = 3;
	counters.T = 2;
	
	//Initialize ocean and battle
	myin.open("ocean.dat");
	for(i=0;i<15;i++)
	{
		for(j=0;j<15;j++)
		{
			myin.get(ocean[i][j]);
			battle[i][j] = '.';
		}
		myin.get(trash);
	}

	do
	{
		//Print the battle
		for(i=0;i<15;i++)
		{
			for(j=0;j<15;j++)
				cout << battle[i][j];
			cout << endl;
		}

		//Print number of missles
		cout << "Missles: " << missles << endl;

		//Get the user guess
		cout << "input a row and column ";
		cin >> row >> col;

		//Check to see if there's a hit
		fire(row, col, ocean, result, ship);

		//update variables
		missles--;
		battle[row][col] = result;
		ocean[row][col] = 'X';
		if(result == 'H')
			updateCounters(counters,ship);
		//determine if ship sunk
		//determine if won
	
	}while((missles != 0) && !won);

	//tell them if they won or lost

	//printShips(ocean);

	return 0;
}

void printShips(char ocean[15][15])
{
	int i,j;

	for(i=0;i<15;i++)
	{
		for(j=0;j<15;j++)
		{
			switch(ocean[i][j])
			{
				case 'F': cout << "Frigate "; break;
				case 'T': cout << "Tender "; break;
				case 'D': cout << "Destroyer "; break;
				case 'S': cout << "Submarine "; break;
				case 'C': cout << "Carrier "; break;
				case 'B': cout << "Battleship "; break;
				case ' ': break;
				default : cout << "error error "; break;
			}
			if(ocean[i][j] != ' ')
				cout << "at location " << i << " " << j << endl;
		}
	}
	return;
}

void fire(int row, int col, char ocean[15][15], char &result, char &ship)
{
	return;
}

the ocean file has to be made separately by 15 by 15, but this is simple and i can do this. what i need help with is the update counter. which is i think to update the map. plese help me out!!!

You are in charge of a high profile software design consulting firm. A customer bursts through the front door, comes running in flailing his arms wildly about, stops at your cubicle, looks you square in the eye and makes the following demand:

the ocean file has to be made separately by 15 by 15, but this is simple and i can do this. what i need help with is the update counter. which is i think to update the map. plese help me out!!!

Q: How do you respond...

You are in charge of a high profile software design consulting firm. A customer bursts through the front door, comes running in flailing his arms wildly about, stops at your cubicle, looks you square in the eye and makes the following demand:

Q: How do you respond...

sry to make this so confusing. in need the function called updateCounter. and what it should do is to update the map to show if i have it the target or not. hope that was clearer.

sry to make this so confusing. in need the function called updateCounter. and what it should do is to update the map to show if i have it the target or not. hope that was clearer.

Translation:

"I'm sorry to make this so confusing. I need to develop a function called, 'updateCounter.' It should update the map to show if I have hit the target or not."


It appears that you load a 2 dimensional array with ship positions. You should compare user input to the corresponding element of the array. If the element is occupied, then return hit, else return miss.

If hit, make a 'hit' assignment to the array, else update the array with a miss indication.

Redraw the array and prompt for next user guess.

how would you write that? sorry, this is not my program, i just was forced to finish it even though i have little to no idea how to write codes.

who's program is it..???

why do you have it....??!??!

more importantly, can I have a cut of what he is paying you..?

who's program is it..???

why do you have it....??!??!

more importantly, can I have a cut of what he is paying you..?

sry shes not paying me or anything.....
i don't even know why i got in this mess, but i did.....
just because i am taking like a computer science class, she forced me to finish this.... i don't know....
i mean, i can pay you like a little bit if you finish it if its not to much.

I'm sorry to say this hombre... unless she is giving it up, you better grow a pair and tell her to do her own @#@$!@#$ homework.

(however, if she is giving it up I'll be glad to assist you in anyway i can)

I'm sorry to say this hombre... unless she is giving it up, you better grow a pair and tell her to do her own @#@$!@#$ homework.

(however, if she is giving it up I'll be glad to assist you in anyway i can)

don't worry about her, i mean, i really need the help. shes out of town, i have an exam tomorrow, and its just a mess. i will probably be able to pay you through paypal if you have it? i don't know, but i really want this to be over with.

shes out of town,

so she's out of town 'taking care of her needs' while you are here having to learn a somewhat complex object oriented programming language in false dellusional hope that you might get a piece of the action.

i can tell you now, that if you haven't closed the deal it's not going to happen.

next time, she has to 'pay up front' if you know what i mean.

so she's out of town 'taking care of her needs' while you are here having to learn a somewhat complex object oriented programming language in false dellusional hope that you might get a piece of the action.

i can tell you now, that if you haven't closed the deal it's not going to happen.

next time, she has to 'pay up front' if you know what i mean.

no. she is an 'older' lady.... i don't know what you are talking about. lol. i do, but she is like 40. i am like 19. and the only reason why i am helping her is because she is like a family friend, and it was just so awkard to refuse.

I'll tell you now, there is absolutely nothing wrong with an older woman. I ask that you expand your horizons to the include the cougar age group.

Next time you see her, tell her that you want to 'sink her battleship.'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.