-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
71 lines (65 loc) · 1.64 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <vector>
using namespace std;
vector <string> board[10];
void createBoard() {
for ( int i = 0; i < 10; i++)
{
board[i] = " ";
}
}
void printBoard() {
cout << " | |" << endl;
cout << " " << board[1] << " | " << board[2] << " | " << board[3] << endl;
cout << "___|___|___|" << endl;
cout << " | |" << endl;
cout << " " << board[4] << " | " << board[5] << " | " << board[6] << endl;
cout << "___|___|___|" << endl;
cout << " | |" << endl;
cout << " " << board[7] << " | " << board[8] << " | " << board[9] << endl;
cout << " | |" << endl;
}
void insertLetter( int pos, char letter ) {
board[pos] = letter;
}
string spaceIsFree( int pos ) {
return board[pos] = " ";
}
void playerMove() {
bool run = true;
while ( run == true )
{
string input;
cout << "Please select a position to place an \'X\' (1-9): ";
getline( cin, input );
try
{
stringstream ss(input);
int move; ss >> move;
throw 400;
if ( 0 < move < 10 )
{
if ( spaceIsFree(move) )
{
insertLetter( move, "X" );
run = false;
}
else
{
cout << "This postion is already occupied!";
}
}
else
{
cout << "Please type a number within the range!";
}
}
catch( int x )
{
cout << "Please type a number!";
}
}
}
int main() {
return 0;
}