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!!!