Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Project - Create a memory game in c++ using structs and pointers. For this exercise, you will create a simple version of the Memory

C++ Project - Create a memory game in c++ using structs and pointers.

For this exercise, you will create a simple version of the Memory Game.

You will again be working with multiple functions and arrays. You will be using pointers for your arrays and you must use a struct to store the move and pass it to functions as needed. Program Design You may want to create two different 4x4 arrays. One to store the symbols the player is trying to match and the second one to be used to show the current state of the game. You could do it with a single array for the symbols, as an alternative design. For the symbols, you can use any eight different characters. Possible options are the digits 1-8, the letters A-H, or a collection of special characters such as: !,@,#,$,%,^,&,*. The only requirement is that there are eight of them. To initialize the symbol array, you will randomly place two copies of each symbol in your 4x4 array. For each turn, you display the current state of the board, showing an X or a SPACE at each location. Each location is an X at the start of the game, SPACES are used to indicate where a symbol pair was found. After showing the current state, you ask for a move. Then you display the state, but at the chosen location, you show the real symbol instead of an X. Then you ask for a second move and display the board with those two locations showing the real symbol instead of Xs. If the two symbols showing are a match, you replace the Xs with SPACES. If they are not a match, you do nothing. Once all Xs have been replaced by SPACES, the game is done.

PROGRAM REQUIREMENTS

You need to have a function to initialize your memory game and return it to main. This can be done with dynamic allocation of the array (as a 1x16 element array instead of a 4x4 one). By using a 1x16 array, it makes it simpler to determine the location to place items.

You need a function to get a move from the player and return it to main. This should ask for a row and column (each between 0 and 3). Validate that each one is in range. Return a struct containing the move as two integers. You can return this as a pointer or by copy, your choice.

You will need a function to display the board. You will pass one or two moves in to this function depending on if it is the first time or the second time. If you want, you can have two separate functions so that you have one with one move and one with two moves. (Remember, you can have two functions with the same name as long as they have different parameter lists.)

Your program should allow the player to repeat playing if they want. You can keep track of how many moves it took if you would like.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions