Question: Programming Concepts STL containers, iterators and algorithms. Task Summary We are going to make two main changes to our code. First, we are going to

Programming Concepts
STL containers, iterators and algorithms.
Task Summary
We are going to make two main changes to our code. First, we are going to allow players to flag a mine. Flagged mines are where the player believes a mine is hidden. This is to help players keep track of their logic for the game.
In order to accommodate this, we are modifying are game board to contain a struct:
struct gameSlot
{
gamePieces piece{ gamePieces::hiddenEmpty };
bool flagged{ false };
};
We now have two pieces of information we need to keep track of for each spot on the board. First, what the spot contains, and, second, whether the player has flagged the spot.
This will require three main changes to the code:
all instances of std::vector must change to std::vector
The displayGameState function will display an f if flagged is true, no matter what value is stored in piece.
the changeGameState function, after asking for a row and column must now ask if the player wants to flag/unflag a mine.
The final change we are going to make is to change two for loops to STL algorithms. The first is a std::find_if in displayGameDone, and the second is a std::generate in boardSetup()
Task 0: Download Base Files (easy)
Click on the github link in blackboard, then clone the repository to your machine.
Task 1: create the struct and change the vector. (moderate)
use ctrl-H to quickly replace all instances of std::vector. You will then need to add .piece to several spots in the code. After this, the game should compile and run.
Task 2: Modify changeGameState (moderate)
Make sure that choosing to flag a mine, changes the item in the vector.
Task 3: Modify displayGameState (moderate)
Modify to display an f when a spot is flagged. This should only be an option for unrevealed spots.
Task 4: Submit completed Assignment (hard)
Modify for loops. Do one at a time, and make sure your code still works.
Task 5: Submit completed Assignment (easy)
You should submit your Visual Studio via github.
Grading:
See the syllabus for grading criteria. Review the slides for coding guidelines I will be looking for!
How to go about writing this code:
Read this programming task specification carefully.
Download and build the project.
Run the base code.
Examine the source code. Particularly, study which variables the functions (those required for the programming task) take as arguments and compare them with what these functions are to do.
Write in English the steps that each function should perform.
Use this plan to write the code.
Write the code incrementally, compiling often. Save your work!
Ask questions early and often!
Extra Credit
(50XP) There are other for loops in the code. You can get 50XP for EVERY loop you change to an STL algorithm. Must be a valid and reasonable change.
(100XP) Players should not be able to reveal a spot that is flagged. To receive these points, when a player chooses a spot on the board:
If it is flagged, it should unflag it.
If it is not flagged, the player should choose between flagging it or revealing it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!