Public feed #890588

Someone

public text v1 · immutable
Raw Edit
·published 2008-02-03 21:30 UTC
rendered paste body
void setShips(Player players[], char size, short whichPlayer)
{
	char input = 'V';
	char ok = 'Y';
	char save = 'N';
	ostringstream outSStream;
	Cell location = {0, 0};
		for(short j = 1; j < SHIP_SIZE_ARRAYSIZE; j++)
		{
			system("cls");
			printGrid(cout, players[whichPlayer].m_gameGrid[0], size);
			outSStream.str("");
			outSStream << "Player " << whichPlayer + 1 << " Enter "
				<< shipNames[j] << " orientation";
			input =  safeChoice(outSStream.str(),'V','H');
			players[whichPlayer].m_ships[j].m_orientation = (input == 'V')?VERTICAL:HORIZONTAL;
			cout << "Player " << whichPlayer + 1 << " Enter " << shipNames[j] <<
				" bow coordinates <row letter><col #>: ";
			location = getCoord(cin,size);


			// if ok
			if(!validLocation(players[whichPlayer], j, size))
			{
				cout << "invalid location. Press <enter>" ;
				cin.get();
				j--; // redo
				continue;
			}

			// your code goes here ...
			


		} // end for j
		save = safeChoice("\nSave starting grid?",'Y','N');
		if(save=='Y')saveGrid(players, whichPlayer, size);
}