-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.cpp
88 lines (79 loc) · 1.08 KB
/
game.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "game.h"
#include "player.h"
#include <iostream>
#include <string>
char intToChar(int num)
{
switch (num)
{
case 1:
return '1';
break;
case 2:
return '2';
break;
case 3:
return '3';
break;
case 4:
return '4';
break;
case 5:
return '5';
break;
case 6:
return '6';
break;
case 7:
return '7';
break;
case 8:
return '8';
break;
case 9:
return '9';
break;
}
return 0;
}
void Game::initialize(char array[])
{
for (int i = 1; i <= 9; i++)
{
//array[i] = '-';
array[i] = intToChar(i);
}
}
void Game::showBoard(char game[])
{
for (int i = 1; i <= 3; i++)
{
std::cout << "| " << game[i] << " ";
}
std::cout << std::endl;
for (int i = 4; i <= 6; i++)
{
std::cout << "| " << game[i] << " ";
}
std::cout << std::endl;
for (int i = 7; i <= 9; i++)
{
std::cout << "| " << game[i] << " ";
}
std::cout << std::endl;
}
bool Game::inGame(char m[])
{
for (int i = 1; i <= 9; i++)
{
if (m[i] >= '1' && m[i] <= '9')
{
return true;
}
}
return false;
}
bool Game::taken(char m[], int digit)
{
return !isdigit(m[digit]);
}