All pastes #1025065 Raw Edit

Unnamed

public text v1 · immutable
#1025065 ·published 2008-05-21 17:58 UTC
rendered paste body
//This is the main file, and will be ran when executed

#include "board.h"
#include "player.h"

using namespace std;

int main(){
	//setup variables
	Board ttt;
	Player* players[2];
	int move = 0;

	//set up players
	players[0] = new Player(1);
	players[1] = new Player(2);

	while(ttt.checkWinner() == 0){
		
		move = 0;  //reset move
		ttt.printBoard(); //print the board
		move = players[ttt.getTurn()-1]->getMove(); //get the player move

		while(!ttt.makeMove(move)){  //get a player to make the correct move
			move = 0;  //reset move
			cout << "Invaild move!  Please try again!\n";  //Tell the player his move was bad
			move = players[ttt.getTurn()-1]->getMove();  //get player move
		}

		cout << endl << endl;
	}

	// -1 if cat won the game
	if(ttt.checkWinner() == -1){
		cout << "Bummer!  Cat won the game!\n";
	} else {
		//get the custom winning message for the player
		players[ttt.checkWinner() - 1]->printWinningMessage();
	}



	return 0;

}