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
|
#include <iostream>
#include "Board.h"
#include <limits>
#include <cctype>
using namespace std;
int main()
{
// Welcoming message.
cout << "Welcome users to my very own tic-tac-toe game. " << endl;
// Object to access the class functions
Board process;
char response1; // A variable to gather input from player1 if they want to quit the game or not
char response2; // A variable to gather input from player2 if they want to quit the game or not
int tileCounter = 0; // Represents how many tiles have been used.
int playerWins1 = 0; // How many times player1 won a match.
int PlayerLose1 = 0; // How many times Player1 lost a match.
int playerLose2 = 0; // How many times player 2 lost a match.
int playerWins2 = 0; // How many times player2 won a match.
int tie = 0; // How many times a match ended up in a tie.
while(toupper(response1) != 'N' || toupper(response2) != 'N')
{
process.choosingLetter(); // Players choose their letter for the game.
cout << endl << endl;
process.draw(); // Creates the board.
tileCounter = 0; // reinitializes after each game.
// Game loop
// If there are no 3 matches, keep playing.
while(!process.isGameOver(tileCounter,playerWins1,PlayerLose1, playerWins2, playerLose2, tie)) // If there are no 3 matches, keep playing.
{
cout << endl;
process.playerMove1(); // Outputs player1's move.
cout << endl << endl << endl;
process.draw(); // Call the board again to see the changes.
cout << endl;
tileCounter++;
if(process.isGameOver(tileCounter,playerWins1,PlayerLose1, playerWins2, playerLose2, tie) == true)
{
break;
}
process.playerMove2(); // Outputs player2's move.
cout << endl << endl;
process.draw();
tileCounter++;
}
process.playAgain(response1, response2);
}
process.scoreBoard(playerWins1,PlayerLose1, playerWins2, playerLose2, tie);
return 0;
}
|