-
Notifications
You must be signed in to change notification settings - Fork 0
/
classview (2).cpp
67 lines (54 loc) · 1.27 KB
/
classview (2).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
#include "classview.h"
#include <iostream>
#include <stdio.h>
using namespace std;
classview::classview (classboard *b){
board =b;
}
void classview::show(){
// printf("\033[2J\033[1;1H");
cout<<" __0___1___2__"<<endl;
for(int i=0;i<3;i++){
cout<<' '<<i<<' '<<"I ";
for(int j=0;j<3;j++){
if(board->getcell(i,j)==0){
cout<<' '<<" I ";
}
if(board->getcell(i,j)==1){
cout<<'X'<<" I ";
}
if(board->getcell(i,j)==2){
cout<<'O'<<" I ";
}
}
cout <<endl;
}
}
int classview::startgame(){
show();
int x,y,s=0;
bool errorvvod;
while(!(board->getnoWin()==9)) {
do{
cout<< "введите положение х"<<' ';
cin >>y;
cout<<"введите положение у"<<' ';
cin>>x;
cout<< "введите символ(1-X,2-O)"<<' ';
cin>>s;
if (cin.fail()){
cout<<endl<<"это не число"<<endl;
cin.clear();
cin.ignore(32767,'\n');
}
if (s==3){return 3;}
errorvvod=board->makemove(x,y,s);
if (errorvvod) cout<<endl<<"ошибка ввода"<<endl;
}
while (errorvvod);
show();
cout<<"iswin"<<board->getisWin()<<endl;
cout<<"nowin"<<board->getnoWin()<<endl;
}
cout<<"ничья";
}