This is one part of instructions for a C++ Battleship game project. I need help with the first header file. The instructions are below, and the starter code for the gameSpecs.h header file is listed after the below instructions:
All of the code for this part must be placed in the gameSpecs.h header file between the #define ___GAME_SPECS___ and #endif lines. This custom header will be included in your cpp file, so it must follow this specification exactly.
1. First, we need a new data type to store ship placement and hit/miss information. Create an enum type named Tile with the following values in the following order: WATER, AIRCRAFT_CARRIER, BATTLESHIP, SUBMARINE, DESTROYER, PATROL_BOAT, MISS, AIRCRAFT_CARRIER_HIT, BATTLESHIP_HIT, SUBMARINE_HIT, DESTROYER_HIT, and PATROL_BOAT_HIT.
2. Create a constant integer named BOARD_LENGTH that is set to 10, which is the height and width of each of the game boards.
3. Create a constant integer array named SHIP_SIZE where the array values are the sizes of each ship. The values must be ordered so that each index in the array corresponds with the matching Tile value. For example, SHIP_SIZE[AIRCRAFT_CARRIER] should equal 5. Since WATER == 0, the first element in the array should just be set to 0.
4. Create a function named tileToSymbol that accepts a Tile and returns a char. Use a switch statement for this function. For every Tile value representing a ship, the first letter in the ship's name should be returned. The letter should be capitalized unless the value indicates a "hit". For example, if the value is PATROL_BOAT, a 'P' is returned. If the value is PATROL_BOAT_HIT, the letter 'p' is returned. For WATER return '.' and for MISS return '~'. As a precaution, if the parameter value does not match any of the cases, output an error message to the screen and return a blank space.
5. Create a function named shipToString that accepts a Tile and returns a string value. In this function, use a switch statement to return the name of the tile without the word "Hit." For example, a parameter value of AIRCRAFT_CARRIER or AIRCRAFT_CARRIER_HIT should return "Aircraft Carrier". As a precaution, if none of the cases are matched, return "Error".
Below is the starter code in gameSpecs.h header file:
/*
* This file holds global constants, data types, and their associated helper functions for the game of battleship.
*/
#ifndef ___GAME_SPECS___
#define ___GAME_SPECS___
#include <string>
using namespace std;
// Put new code here.
#endif