Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "fun.h"
- #include <iostream>
- #include <Windows.h>
- Game::Game(){
- system("COLOR 8c");
- }
- char Game::check[3][3];
- Game::Game(int i,char p ,int s):input(i),player(p),score(&s){
- status = false;
- status3= false;
- status4= false;
- system("COLOR 4f");
- }
- void Game::setup(){
- if(input<4 && check[0][input-1]==NULL)
- check[0][input-1]= player;
- else if(input>=4 && input<=6 && check[1][input-4]==NULL)
- check[1][input-4] = player;
- else if(input>=7 && check[2][input-7]==NULL)
- check[2][input-7] = player;
- else{
- std::cout<<"this element not empty try again"<<std::endl;
- status3 = true;
- }
- for(int x=0; x<3; x++){
- std::cout<<"-------------"<<std::endl;
- for(int d=0; d<3; d++){
- if(d!=0)
- std::cout<<" ";
- std::cout<<"| ";
- std::cout<<check[x][d];
- if(d==2)
- std::cout<<" |";
- }
- std::cout<<std::endl;
- if(x==2)
- std::cout<<"-------------"<<std::endl;
- }
- }
- void Game::PanelNum(){
- int counter = 0;
- for(int y=0; y<3; y++){
- std::cout<<"-------------"<<std::endl;
- for(int g=0; g<3; g++){
- if(g!=0)
- std::cout<<" ";
- std::cout<<"| ";
- std::cout<<++counter;
- if(g==2)
- std::cout<<" |";
- }
- std::cout<<std::endl;
- if(y==2)
- std::cout<<"-------------"<<std::endl;
- }
- }
- void Game::win(){
- using namespace std;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = check[t][q];
- }
- }
- if(win2[0][0]==player&&win2[0][1]==player&&win2[0][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[0][0]==player&&win2[1][1]==player&&win2[2][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[2][0]==player&&win2[1][1]==player&&win2[0][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[1][0]==player&&win2[1][1]==player&&win2[1][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[2][0]==player&&win2[2][1]==player&&win2[2][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[0][0]==player&&win2[1][0]==player&&win2[2][0]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[0][1]==player&&win2[1][1]==player&&win2[2][1]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- else if(win2[0][2]==player&&win2[1][2]==player&&win2[2][2]==player){
- //Player win
- ++*score;
- cout<<"Player " <<player<<" WIN PLAY AGAIN.."<<endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q] = NULL;
- check[t][q] = NULL;
- }
- }
- status = true;
- }
- //GameOver
- else if(win2[0][0]!=NULL && win2[0][1]!=NULL && win2[0][2]!=NULL && win2[1][0]!=NULL &&
- win2[1][1]!=NULL && win2[1][2]!=NULL && win2[2][0]!=NULL && win2[2][1]!=NULL &&
- win2[2][2]!=NULL){
- std::cout<<"Game over 'No one win'.."<<std::endl;
- for(int t=0; t<3; t++){
- for(int q=0; q<3; q++){
- win2[t][q]= NULL;
- check[t][q]=NULL;
- }
- }
- status4= true;
- }
- }
- int Game::Scores(){
- return *score;
- }
- bool Game::status2(){
- return status3;
- }
- bool Game::status5(){
- return status4;
- }
- bool Game::status1(){
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement