I am asking again because I need it done correctly. This is a simplified version
ID: 3535049 • Letter: I
Question
I am asking again because I need it done correctly.
This is a simplified version of the mine sweep game. You will randomly populate a grid with bombs. The user will then be allowed to guess the locations of empty spots until they run into a bomb. Once they have blown up, you will show the grid and report how many spaces were guessed before they encountered the bomb. The object of the game is to guess as many free spaces without hitting a bomb.
Specifics:
For this game, you will use a 5 x 5 2Darray of characters to be the game board. The board will be marked with an 'A' to simulate an available location. The board will be marked with a 'B' to simulate that there is a bomb. The board will be marked with a 'T to simulate a space that has been selected
Functions
The following functions are required
beginTheBoard - Populates the array with the 'O' character to show an available space.
printTheBoard - Prints the board out 5 rows by 5 columns. Every column must be tab spaced.
makeToRowsAndCols - With this function you will take a value between 1 and 25 and convert the value to row and Colum locations. You will have to use reference parameters to do this.
putTheBombsOnBoard - Randomly populates 5 spaces with  bombs. You will use the '*' character to be the bombs
markAllSpaces - This function will be used to check and mark the board depending on what character is in the location. It takes as parameters the 2D array that represents the board and the row column location to check. If the location has an 'O' in it you will place an X in the location to mark the spot and return HARMLESS. If the location has an 'X' in it you will return TAKEN. If it has a '*' character you will return BOOM. To recap the function should return the following:
HARMLESS - if there was no bomb and you could place an X in the location
TAKEN if the space had previously been chosen.Â
BOOM if the space chosen contains the * character
BOOM, HARMLESS, and TAKEN should be defined as constants in global scope and have the following values:
BOOM = 1 HARMLESS = 0; TAKEN = -1
The game flows as follows:
Seed random number generator Initialize the board Populate board with bombs Get location from keyboard Convert location to row column locations Mark the space Check the value returned from markAllSpaces If MARKED decrement the count and display a message indicating they selecte a space more than once if SAFE increment the count and let the user know they selected a safe space The game should continue until the value returned from markAllSpaces is BOOM which means loop back to number 4.
it is ok to use a do-while loop since we are forcing people to play it at least once.
What you can not do
global variables except for the constants specified.
cin in any funciton other than main
cout in any funciton other than main and printTheBoard
goto statements
Explanation / Answer
please rate - thanks didn't know what to do with the count--any changes needed, let me know. I will make them #include #include #include #define BOOM 1 #define HARMLESS 0 #define TAKEN -1 using namespace std; void beginTheBoard(char[][5]); void printTheBoard(char[][5]); void makeToRowsAndCols(int,int&,int&); void putTheBombsOnBoard(char[][5]); int markAllSpaces(char[][5],int,int); int main() {char board[5][5]; int loc,row,col,value,count=0; srand(time(0)); beginTheBoard(board); putTheBombsOnBoard(board); do {coutloc; while(loc25) {coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.