// Stephen Bassoli // CSE 124 Section 1 // Lab 2 #ifndef Board_H #define Board_H #include "Ship.h" struct Spot { bool ship; bool hit; int ShipNumber; }; class Board { private: Spot Grid[12][12]; int ShipsLeft; Ship Ships[20]; int TempShip; public: Board(); // Input: None // Precond: None // Process: Sets ships length to 3 // Output: None // Postcond: None void Place(int three, int four, int five); // Input: Number of ships of each type // Precond: None // Process: Randomly places the specified number of ships on the board // Output: The ships have been placed on the board // Postcond: Ships must all have been placed or the program terminates void Clear(); // Input: None // Precond: None // Process: Clears the board of all ships and hits // Output: None // Postcond: None bool Mark(int R, int C); // Input: Row and column that is to be marked // Precond: None // Process: Marks the specified spot with a hit, returns // true if there is no mark there // Output: Spot is marked // Postcond: None bool IsHit(int R, int C); // Input: Row and column that is marked // Precond: There must be a mark there // Process: Determines if specified spot is a hit // Output: Returns true if there is a ship there // Postcond: None bool IsSink(); // Input: There must be a hit // Precond: None // Process: Determines if the hit ship is sunk // Output: Returns true if the hit ship is sunk, ie hits == length // Postcond: None bool IsWin(); // Input: None // Precond: A ship must just have been sunk // Process: Determines if there are no ships left on the board // Output: Returns true if ShipsLeft == 0 // Postcond: None void PrintBoard()const; // Input: None // Precond: None // Process: Prints the board // Output: A board is printed displaying hits and misses // Postcond: None int ReturnShipsLeft(); // Input: None // Precond: None // Process: Returns the number of shipsleft // Output: Number of Ships Left // Postcond: None }; #endif