fstream* file = new fstream("GameDetails.txt", fstream::out);
ofstream out;
out.open("GameDetails.txt",ios::ate);
while ( more )
{
game.Tic_Tac_Toe_Board();
player = game.Pick_Player();
fstream* file = new fstream("GameDetails", fstream::in);
*file << left << setw(30) << setw(25) << "Player" << setw(25) << "Wins" << setw(10) << right << "LOSES" << endl;
*file << "------------------------------------------------------------------------------------------" << endl;
char player;
int win;
int lose;
char answer;
do
{
cout<<"Enter Player: "<<endl;
cin >> player;
cout<<"Enter Wins : "<<endl;
cin >> win;
cout<<"Enter Loses : "<<endl;
cin >> lose;
*file << left << setw(30)<< setw(25) << player << setw(25) << win<< setw(10) << right << lose << endl;
printf("Enter another (Y / N) : ");
cin >> answer;
} while (answer == 'Y');
cout << " Current Player " << player<<endl;
out<<"Current Player: "<<player << endl;
cout << " Enter Row Index ( 0,1,2): " << endl;
cin >> row;
out<<"Enter Row: "<<row << endl;
cout << " Enter Column Index (0,1,2): " << endl;
cin >> column;
out<<"Enter Column: "<<column << endl;
out<<"<--------------->"<<endl;
game.Choice_of_Row(row);
game.Choice_of_Column(column);
test = game.Check_Move( game.Pick_Row(), game.Pick_Column());
if ( test == 1)
{
check = game.Check_Board();
}
else
{
while ( test == 0 )
{
ofstream out;
out.open("GameDetails.txt",ios::ate);
cout << " Current Player " << game.Pick_Player() <<" Invalid Choice" << endl;
out<<"Current Player: "<<game.Pick_Player << endl;
cout << " Enter Row Index ( 0,1,2): " ;
out<<"ROW: "<<row << endl;
cin >> row;
cout << endl;
cout << " Enter Column Index ( 0,1,2): " ;
cin >> column;
cout << endl;
game.Choice_of_Row(row);
game.Choice_of_Column(column);
test = game.Check_Move(game.Pick_Row(),game.Pick_Column());
} //end of while loop
check = game.Check_Board();
}
if ( check == 1 || check == 2)
{
break;
}
else if ( check == 3 )
{
game.Tic_Tac_Toe_Board();
cout << " The game is tied. " << endl;
}
if ( player == 1)
{
player = 2;
}
else
{
player = 1;
}
game.Choice_by_Player(player);
// out.close();
}
// end of outer while loop
game.Tic_Tac_Toe_Board();
cout << " Player " << check << " wins. " << endl;
out<<"Player: "<<check<<"WINS" << endl;
alflash 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.