Homework Help - Post Questions, Assignments & Papers

Studypool values your privacy. Only questions posted as Public are visible on our website.

C++ array problem

Anonymous

labelProgramming

timer
Asked: Jul 19th, 2013

Question description

must use C++

Objective

To understand and implement software using arrays and previously learned programming constructs.

Instructions

For this assignment you willcreate a Memory Game similar to the card game that many of us probablyplayed as kids. For the Memory Game, you will allow for the user to select anindex of an array of characters and try to find the matching character. If theguess is wrong, you “flip the card back over” and do not reveal it. If they geta matching pair, then you display both of the characters. You should keep trackof how many guesses (rounds) the user requires to unveil all of the matches.

The array will have 10elements, thus, five pairs. You could choose A,B,C,D, and E just to keep thingssimple or use a different set of characters. Behind the scenes, you may have anarray that looks like this, for example:

[ ‘A’ ‘B’ ‘B’ ‘A’ ‘C’ ‘D’ ‘D’‘C’ ‘E’ ‘E’ ]

Or anything of the sort. However, the user will (at startup) see the following:

[ - - - - - - - - - - ]

To indicate that none of the “cards” have been unveiled yet.

Print the results at each stage of interaction with the user. For example, a sample interaction could be as follows:

[ - - - - - - - - - - ] Tries: 0

>>0

[ A - - - - - - - - - ] Tries: 1

>>1

[ A B - - - - - - - - ] Tries: 2

No match, sorry.

[ - - - - - - - - - - ]

>>3

[ - - - A - - - - - - ] Tries: 3

>>0

[ A - - A - - - - - - ] Tries: 4

You’ve made a match! Please continue!

[ A - - A - - - - - - ]

Etc.

So the user continues playing until all the letters are recovered. At the end you should say, “congratulations, you’ve matched all the cards in someNumber tries!

Recommendations/Hints

Use parallel arrays One contains the actual letters One is used todisplay the appropriate cards that have been revealed (or not, i.e. ‘-‘ back tothe user)

You should design a class called CMemoryGame to maintain the state of thegame, interact with the user, and determine winning state. Failure to use aclass will result in significant loss of points. You must also write a driver in main.cpp that will use objects of type CMemoryGame that will allow me to test your programs.