#include #include #include "fleet.h" using namespace std; //--------------------------------------------------------------------------------- // Function: main() // File: SinkTheFleetleet.cpp // Title: Set ShipInfo // Description: // Runs the Sink the Fleet Game // Programmer: // // Date: // // Version: // // Environment: Hardware:IBM Pentium+ // Software: Windows XP or 98+ with .NET framework for execution; // Compiles under Microsoft Visual C++ 2005 // // Input: // // Output: // // Calls: initializePlayer() // allocMem() // safeChoice() // getGrid() // printGrid() // resetGrid() // setships() // header() // getCoord() // deleteMem() // endBox() // // Called By: n/a // // Parameters: void // // Returns: int -- EXIT_SUCCESS upon successful completion // // History Log: // // //--------------------------------------------------------------------------------- extern const char* shipNames[7]; int main(void) { short numRows = SMALLROWS; // total number of rows in the array short numCols = SMALLCOLS; // total number of columns in the array char again = 'N'; char gridSize = 'S'; short whichPlayer = 0; bool gameOver = false; bool reshot = false; Cell coord = {0,0}; string message; string filename; Ship shipHit = NOSHIP; Player game[NUMPLAYERS] ; // the two players in an array // other stuff ... do { system("cls"); cout << endl; header(cout); gridSize = safeChoice("Which size grid to you want to use",'S','L'); if( gridSize == 'L') { numRows = LARGEROWS; numCols = LARGECOLS; } else { numRows = SMALLROWS; numCols = SMALLCOLS; } initializePlayer(game); initializePlayer(game+1); // dynamically create the rows of the array allocMem(game,gridSize); // ... your code goes here for(whichPlayer = 0; whichPlayer < NUMPLAYERS; whichPlayer++) { setShips(game, gridSize, whichPlayer); } whichPlayer = 0; while(!gameOver) { // ... a lot more stuff ... // whichPlayer = !whichPlayer; // switch players } again = safeChoice("Would you like to play again?",'Y','N'); } while(again == 'Y'); return EXIT_SUCCESS; }