Esempio n. 1
0
void Game::NextTurn()
{
	playerOnesTurn = !playerOnesTurn;

	string currentPlayerName = playerOnesTurn ? player1.GetName() : player2.GetName();
	cout << "There are " << pile.GetSticks() << " sticks left." << endl;
	
	bool validValue = false;
	int sticksToRemove;
	while( !validValue )
	{
		cout << endl;
		cout << "It is " << currentPlayerName << "'s turn." << endl;
		cout << "How many sticks do you want to remove? : ";
		cin >> sticksToRemove;
		if( sticksToRemove > 0 &&
			sticksToRemove <= 4 &&
			sticksToRemove <= pile.GetSticks() )
		{
			validValue = true;
		}
		else
		{
			cout << sticksToRemove << " is not a valid number." << endl;
		}
	}
	pile.RemoveSticks( sticksToRemove );
}
Esempio n. 2
0
string Game::GameOver()
{
	if( pile.GetSticks() == 0 )
	{
		return playerOnesTurn ? player1.GetName( ) : player2.GetName( );
	}
	return "";
}