Learning Goal: I’m working on a c++ question and need an explanation and answer to help me learn.
C++ source file name: Memory.cpp
File name must be Memory.cpp
Write a program that plays a memory game with cards containing upper-case letters. The cards are laid out in a 4×4 grid with row and column indices from 0 to 3, as follows (the left diagram with the dollar signs represent the back of the card, the right diagram represents the front of the card. Note that the letters on the cards should be randomly generated from uppercase A-Z each time the game is played from the start): Download Sample program)
0 1 2 3 0 | $ | $ | $ | $ ——————- 1 | $ | $ | $ | $ ——————- 2 | $ | $ | $ | $ ——————- 3 | $ | $ | $ | $ ——————- |
0 1 2 3 0 | K | M | T | P ——————- 1 | P | Y | K | X ——————- 2 | G | T | E | Y ——————- 3 | M | X | E | G ——————- |
Note that each letter is represented exactly twice in the right diagram. The objective of the game is to find as many matching pairs as possible.
Each round of gameplay should do the following:
If there are no cards left to play (all matches have been found) the player wins and the game should print their final points and end. See the sample outputs for more details on gameplay.
Required Functions:
You code must have at least the following two functions. The parameters passed can be different than what is shown below. You may use any other functions you wish:
void print_board(char in_board[][BOARD_SIZE]);
This function prints the current board to the screen with matched cards flipped to show their letter and unmatched cards unflipped.
void fill_board(char in_board[][BOARD_SIZE]);
This function fills the board with randomly selected uppercase letters in the range A-Z. Note that each letter generated must appear exactly twice on the board.
Your program’s output must match the output below as exactly as possible.
Scenario 1: One Round, Cards Match
(the matched cards stay flipped to their letter for the rest of the game):
Welcome to Memory Game! Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | $ ----------------- 2 | $ | $ | $ | $ ----------------- 3 | $ | $ | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: F Pick first card (row, column): 2,3 Pick second card (row, column): 1,3 Cards match! You get a point! Your current points: 1 Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | A ----------------- 2 | $ | $ | $ | A ----------------- 3 | $ | $ | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: Q Your total points: 1 Goodbye!
Scenario 2: One Round, Cards Don’t Match
(the chosen cards are flipped to their letter after the non-match is announced):
Welcome to Memory Game! Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | $ ----------------- 2 | $ | $ | $ | $ ----------------- 3 | $ | $ | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: F Pick first card (row, column): 2,2 Pick second card (row, column): 1,3 Cards do not match! Try again! Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | X ----------------- 2 | $ | $ | B | $ ----------------- 3 | $ | $ | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: Q Your total points: 0 Goodbye!
Scenario 3: Multiple Rounds, Some Matches, Some Non-Matches:
(matched cards stay flipped to their letter, but non-matched go back to the $ after they’re shown):
Welcome to Memory Game! Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | $ ----------------- 2 | $ | $ | $ | $ ----------------- 3 | $ | $ | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: F Pick first card (row, column): 3,1 Pick second card (row, column): 2,2 Cards match! You get a point! Your current points: 1 Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | $ ----------------- 2 | $ | $ | W | $ ----------------- 3 | $ | W | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: F Pick first card (row, column): 0,2 Pick second card (row, column): 1,1 Cards do not match! Try again! Here's the board: 0 1 2 3 0 | $ | $ | K | $ ----------------- 1 | $ | Q | $ | $ ----------------- 2 | $ | $ | W | $ ----------------- 3 | $ | W | $ | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: F Pick first card (row, column): 3,2 Pick second card (row, column): 2,3 Cards do not match! Try again! Here's the board: 0 1 2 3 0 | $ | $ | $ | $ ----------------- 1 | $ | $ | $ | $ ----------------- 2 | $ | $ | W | X ----------------- 3 | $ | W | P | $ ----------------- Choose an option: (F) Find a match (Q) Quit Choice: Q Your total points: 1 Goodbye!
Submissions will be screened for plagiarism and other academically dishonest practices so you MUST do entirely your own work. You may help each other to understand and mathematically grasp the problems, but all submitted work must be unique and original. Please submit your assignment by the due date to the Assignment 3 location in Canvas.
Note: There are MANY solutions to this assignment online. Using these solutions too heavily, like copying and pasting parts or entire code solutions, is also considered Plagiarism.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more