Advertisement
MiDo3

TicTacToe main (main.cpp)

Jan 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include <iostream>
  2. #include "fun.h"
  3. #include <conio.h>
  4. #include <cstdlib>
  5. #include <windows.h>
  6.  
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main(){
  12.     Game Player;
  13.         int ScoreX = 0;
  14.         int ScoreO = 0;
  15.     cout<<"PlayerX Score : "<<ScoreX<<"\t"<<"PlayerY Score : "<<ScoreO<<endl;
  16.     cout<<endl;
  17.     Player.PanelNum();
  18.     cout<<endl;
  19.     while((ScoreO < 10) && (ScoreX < 10)) {
  20.     char playerX1 = 'X';
  21.     char playerO1 = 'O';
  22.     int numX;
  23.     int numO;
  24.         restart :
  25.     if(ScoreX > 9) goto end;
  26.     cout<<"Player X : ";
  27.     if(!(cin>>numX)){
  28.        cin.clear();
  29.        cin.ignore();
  30.        cout<<"Invaild numbers only between 1 - 9 "<<endl;
  31.     goto restart;
  32.     }
  33.  
  34.  
  35.     if(numX > 9){
  36.         cout<<"Invaild numbers only between 1 - 9 "<<endl;
  37.         goto restart;
  38.     }
  39.     Game PlayerX(numX,playerX1,ScoreX);
  40.     cout<<endl;
  41.     system("cls");
  42.     cout<<"PlayerX Score : "<<ScoreX<<"\t"<<"PlayerY Score : "<<ScoreO<<endl;
  43.     cout<<endl;
  44.     Player.PanelNum();
  45.     cout<<endl;
  46.     PlayerX.setup();
  47.     if(PlayerX.status2()==true){
  48.         goto restart;
  49.     }
  50.  
  51.     PlayerX.win();
  52.     if(PlayerX.status5()==true){
  53.         goto restart;
  54.     }
  55.     ScoreX = PlayerX.Scores();
  56.         if(PlayerX.status1()==true){
  57.         goto restart;
  58.     }
  59.     cout<<endl;
  60.     start :
  61.     if(ScoreO > 9) goto end;
  62.     cout<<"Player Y : ";
  63.     if(!(cin>>numO)){
  64.        cin.clear();
  65.        cin.ignore();
  66.        cout<<"Invaild numbers only between 1 - 9 "<<endl;
  67.        goto start;
  68.     }
  69.     Game PlayerO(numO,playerO1,ScoreO);
  70.     if(numO > 9){
  71.         cout<<"Invaild numbers only between 1 - 9 "<<endl;
  72.         goto start;
  73.     }
  74.     cout<<endl;
  75.     system("cls");
  76.     cout<<"PlayerX Score : "<<ScoreX<<"\t"<<"PlayerY Score : "<<ScoreO<<endl;
  77.     cout<<endl;
  78.     Player.PanelNum();
  79.     cout<<endl;
  80.     PlayerO.setup();
  81.     if(PlayerO.status2()==true){
  82.         goto start;
  83.     }
  84.     PlayerO.win();
  85.     if(PlayerO.status5()==true){
  86.         goto start;
  87.     }
  88.     ScoreO = PlayerO.Scores();
  89.         if(PlayerO.status1()==true){
  90.         goto start;
  91.     }
  92.     cout<<endl;
  93.     }
  94.     end :
  95.     Sleep(250);
  96.     system("cls");
  97.     system("color 28");
  98. if(ScoreX > ScoreO && (ScoreX+ScoreO) >= 10)
  99.     cout<<"Player X won the game.."<<endl;
  100. if(ScoreX < ScoreO && (ScoreX+ScoreO) >= 10)
  101.    cout<<"Player Y won the game.."<<endl;
  102.  
  103.     _getch();
  104.  
  105.     return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement