MichaelC1993
2011-02-27 14:55:44 UTC
code:
#include
#include
using namespace std;
string grid [3][3];
grid[0][0] = "1";
grid[0][1] = "2";
grid[0][2] = "3";
grid[1][0] = "4";
grid[1][1] = "5";
grid[1][2] = "6";
grid[2][0] = "7";
grid[2][1] = "8";
grid[2][2] = "9";
string player_x (int player_x_move);
string player_o (int player_o_move);
void show_game_grid ();
string player_x (int player_x_move)
{
switch (player_x_move)
{
loop:
case 1: grid[0][0] = "x";
break;
case 2: grid[0][1] = "x";
break;
case 3: grid[0][2] = "x";
break;
case 4: grid[1][0] = "x";
break;
case 5: grid[1][1] = "x";
break;
case 6: grid[1][2] = "x";
break;
case 7: grid[2][0] = "x";
break;
case 8: grid[2][1] = "x";
break;
case 9: grid[2][2] = "x";
break;
default: cout << "Invalid choice, please enter another grid space" << endl;
goto loop;
}
return 0;
}
string player_o (int player_o_move)
{
switch (player_o_move)
{
loop1:
case 1: grid[0][0] = "o";
break;
case 2: grid[0][1] = "o";
break;
case 3: grid[0][2] = "o";
break;
case 4: grid[1][0] = "o";
break;
case 5: grid[1][1] = "o";
break;
case 6: grid[1][2] = "o";
break;
case 7: grid[2][0] = "o";
break;
case 8: grid[2][1] = "o";
break;
case 9: grid[2][2] = "o";
break;
default: cout << "Invalid choice, please enter another grid space" << endl;
goto loop1;
}
return 0;
}
void show_game_grid()
{
cout << grid[0][0];
cout << grid[0][1];
cout << grid[0][2] << endl;
cout << grid[1][0];
cout << grid[1][1];
cout << grid[1][2] << endl;
cout << grid[2][0];
cout << grid[2][1];
cout << grid[2][2] << endl << endl;
}
int main()
{
void show_game_grid();
cout << "Player 1, it is your turn, you are X's" << endl << "Press the number you wish to place your 'X' on the grid" << endl << endl;
string player_x (int player_x_move);
void show_game_grid();
}
compiler errors:
TTT.cpp:8: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:9: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:10: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:11: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:12: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:13: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:14: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:15: error: expected constructor, destructor, or type conversion before ‘=’ token
TTT.cpp:16: error: expected constructor, destructor, or type conversion before ‘=’ token
Compilation failed.
Again, I am sure the error is quite obvious and it is just me being stupid but I would appreciate the help here,
~ Thanks, Michael