can any one help me. i am suppose to write a battleship game as for my class and since i never played the game befor i have no clue on what i'm doing or what to do.
here is what i have so far. i don't get the cding that i wrote so if any one has any suggestions please do so. thanks alot.
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
const int size_x = 10;
const int size_y = 10;
int field[size_x][size_y];
void board(int location [size_x][size_y], char direction);
void main(string Carriers, string battleship, string cruiser,string submarine, string destroyer);
void check(string Carriers, string battleship, string cruiser,string submarine, string destroyer);
void location(int& size_x, int& size_y);
int main()
{
srand((unsigned) time(NULL));
cout << fixed << showpoint << setprecision(5);
for ( int i = 0; i < size_x; ++i )
{
cout << size_y <<" " << rand() % 10 << endl;
}
return 0;
}
//location function
void location(int& size_x, int& size_y)
{
}
void board(int location [size_x][size_y], char direction);
{
int Continue(10);
int place[x][y];
while (Continue == 10)
{
cout << "where do you want to place your piece" ;
cin >> place;
cout << endl;
int print_x,print_y;
y1 = position.substr(0,1);
x1 = position.substr(1,1);
if (x1 == "1")
print_x = 1;
if (x1 == "2")
print_x = 2;
if (x1 == "3")
print_x = 3;
if (x1 == "4")
print_x = 4;
if (x1 == "5")
print_x = 5;
if (x1 == "6")
print_x = 6;
if (x1 == "7")
print_x = 7;
if (x1 == "8")
print_x = 8;
if (x1 == "9")
print_x = 9;
if (x1 == "10")
print_x = 10;
if (y1 == "A" || y1 == "a")
print_y = 10;
if (y1 == "B" || y1 == "b")
print_y = 9;
if (y1 == "C" || y1 == "c")
print_y = 8;
if (y1 == "D" || y1 == "d")
print_y = 7;
if (y1 == "E" || y1 == "e")
print_y = 6;
if (y1 == "F" || y1 == "f")
print_y = 5;
if (y1 == "G" || y1 == "g")
print_y = 4;
if (y1 == "H" || y1 == "h")
print_y = 3;
if (y1 == "I" || y1 == "i")
print_y = 2;
if (y1 == "J" || y1 == "j")
print_y = 1;
print_y++;
print_x++;
}
}