Language is c++ Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the Windows operating system would contain a game called M inesweeper. The player would be presented with a grid, where they would have to click an empty part of the map. If they clicked on a hidden mine, the game would be instantly over. However, if they clicked a safe spot, a hint about nearby mines would be displayed and the player would click another spot. The goal would be to flag all the hidden mines without hitting one. (As an aside, many people did not know these rules and just clicked around randomly until they hit a mine) We will be developing a simplified version of this game. You will prompt the user for a grid size and then created a 2D array with equal width and height (C++ students: Check the Appendix for more information on how to do this). You will initialize the 2D char array with each element equallying a ‘?’ symbol. You will then randomly generate one “mine” value per column in the 2D and store their row locations in a separate 1D array (the 1D array’s index will represent the column of the 2D array). The player will be prompted the user to enter an X and Y coordinate on the grid. If the space is "free”, you will replace the value at that index with a ‘_’ symbol. If the space has a hidden mine, you will place an ‘X’ symbol at that index instead. Afterwards, print the 2D array again. If the player hit a mine, tell them they lost and that the game is over. Otherwise, conduct a linear search of the 2D array and count how many ‘_’ symbols there are (Hint: Use a nested FOR loop). If the count equals the grid size, tell the player they won. Hint: Reference your code from past Assignments as a starting point for this one. I included sample outputs in the pictures
Language is c++
Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the Windows
We will be developing a simplified version of this game. You will prompt the user for a grid size and then created a 2D array with equal width and height (C++ students: Check the Appendix for more information on how to do this). You will initialize the 2D char array with each element equallying a ‘?’ symbol. You will then randomly generate one “mine” value per column in the 2D and store their row locations in a separate 1D array (the 1D array’s index will represent the column of the 2D array).
The player will be prompted the user to enter an X and Y coordinate on the grid. If the space is "free”, you will replace the value at that index with a ‘_’ symbol. If the space has a hidden mine,
you will place an ‘X’ symbol at that index instead. Afterwards, print the 2D array again.
If the player hit a mine, tell them they lost and that the game is over. Otherwise, conduct a linear search of the 2D array and count how many ‘_’ symbols there are (Hint: Use a nested FOR loop). If the count equals the grid size, tell the player they won.
Hint: Reference your code from past Assignments as a starting point for this one.
I included sample outputs in the pictures
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images