Project Description
Background
In this project, you are going to recreate a traditional matching game on the computer. Unfortunately, we don’t have a card to turn over, so we will have to pretend by revealing information on the computer screen!
Your Task
The Basics
To start with, the game will have 10 different items of your choice, such as animals, colors, food, Marvel characters, etc. You will use these to create a 4 by 5 grid with each item randomly placed twice in the grid.
Each turn, the user will first select one item, at which point you will reveal the item. They then select another item and again you reveal it. If it is a match, both items remain revealed, otherwise, you hide the items. Once all items are revealed, the game is over and you print out how many turns it took to solve.
Unfortunately, it is still a little too easy to scroll up and cheat, but we will not worry about that for this gameplay.
The Details
Your program should use 2 grids, a solution grid initially populated with all of the correct items, and a guessing grid initially populated with all xxxx
s. As the user guesses correctly, the guess grid will slowly get revealed. Each time a match is found, a counter will increment and when you get to the number of items, you win!
To populate your grid, you will use a vector list of items that you can hardcode in. That list will then be used to randomly place items into the solution grid. There are several ways to do this, so be creative (but efficient).
Starter Code
In addition to the constant values, you are given an outline of several functions to create, including one to print the grid, one to populate a grid, and one to play a turn. More details on these can be found in the starter code.
As a side note, the playTurn
function takes the two grids as pass-by-reference. If you have not seen pass-by-reference, it is ok, but you should know that this means any value updated in the function will also be updated in the original item, so you do not need to pass the vectors back.