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
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
class myclass{
public:
void grid(char a[2],bool b){
string a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,c1,c2,c3,c4,c5,d1,d2,d3,d4,d5,e1,e2,e3,e4,e5;
if ( a[2]=='32'){
a1=a2=a3=a4=a5=b1=b2=b3=b4=b5=c1=c2=c3=c4=c5=d1=d2=d3=d4=d5=e1=e2=e3=e4=e5='?';
}
switch (a[2]) {
case 'a1':
a1='X';
break;
}
cout <<"\n _______________________\n"<<" II a I b I c I d I e II\n"<<" -----------------------"<<endl;
cout <<" 1: II "<<a1<<" I "<<b1<<" I "<<c1<<" I "<<d1<<" I "<<e1<<" II"<<endl;
cout <<" _______________________\n"<<" 2: II "<<a2<<" I "<<b2<<" I "<<c2<<" I "<<d2<<" I "<<e2<<" II"<<endl;
cout <<" _______________________\n"<<" 3: II "<<a3<<" I "<<b3<<" I "<<c3<<" I "<<d3<<" I "<<e3<<" II"<<endl;
cout <<" _______________________\n"<<" 4: II "<<a4<<" I "<<b4<<" I "<<c4<<" I "<<d4<<" I "<<e4<<" II"<<endl;
cout <<" _______________________\n"<<" 5: II "<<a5<<" I "<<b5<<" I "<<c5<<" I "<<d5<<" I "<<e5<<" II\n"<<" _______________________\n"<<endl;
}
};
int main() {
myclass get;
srand(time(0));
bool y;
string p1,p2;
int x;
x =1+(rand() %6);
char z[2];
z[2]='32';
cout << "Welcome to 'tic tac toe' multiplayer game\nnow insert player names\nPlayer 1:";
cin >> p1;
cout <<"Player 2:";
cin >> p2;
if (x<4){
cout <<p1<<" is first"<<endl;
y=true;
}
else {
cout <<p2<<" is first"<<endl;
y=false;
}
get.grid(z[2],y);
cout << "type in letter and number of square, where you want place your symbol"<<endl;
cin >>z;
get.grid(z[2],y);
cout <<z<<endl;
return 0;
}
|