CS215 Programming Assignment 3 Card Matching Game solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (11 votes)

For this project you will not be implementing the entire program. You will be
supplied with a program shell that will provide the functional framework for your
application. The program shell is available for checkout from the class program
repository (“https://calypso.vis.uky.edu/cs215/tags/assignments/spr2012/cs215Pgm3”).
In these specifications, you will be given requirements for a set of functions that you will
need to implement and add to the shell you are given.
For this project you are being introduced to the concept of Design by Contract. In
DbC, specifications are given in terms on INPUTS, OUTPUTS, and SIDE EFFECTS.
The INPUTS describe what data the framework will pass to you (i.e. the parameters
passed to your functions by the application framework). The OUTPUTS specify the
results you will return back (the return value). Hence, this gives us the concept of a
contract (I’ll give you this, you give me that). SIDE EFFECTS specify additional logic
that will needed to be performed by your function that does not affect what is returned to
the caller.
As with program 2, you are forced to use the function signatures given in the
programming assignment. Unlike program 2, you will not be able to get around this since
you are forced to use the supplied framework.
Project 3 will implement a card matching game. The playing cards will be
displayed face down in a four by twelve matrix. The player will click on a card and it will
be turned face up. The player will then click on a second card and if it matches the first
card (same rank and suit) , they will be removed from play. The game is over when all
cards are matched. Your project will use a Pinochle deck of 48 cards (two each of 9
through Ace for every suit).
The program will use the PlayingCard and CardDeck classes that you
created as part of a recent assignment. You will most likely need to implement additional
member functions in these classes. You will also implement five functions within the
cs215pgm3.cpp file.
void getCard(int row, int column, char cardString[])
A character array for storing the output, the row of the card, the column of the
This function should find the card represented by the row and column passed in
the function call and updates the char array that was passed with a character string
representing the card. This string should always be 2 characters long followed by
a null byte. Example representations of the cards are as follows:
2 of spades = ‘S2’
10 of hearts = ‘HT’
Jack of diamonds = ‘DJ’
Queen of clubs = ‘CQ’
Ace of spades = ‘SA’
void shuffleCards()
This function will reorder the Cards in your Deck in a random sequence. There
should also be a way for your program to associate the Cards in your Deck with
the four by twelve display on the GUI.
void matchTwoCards(int row1, int column1, int row2, int
Two sets of row/column pairs that each represent a playing card of the game
If the two cards indicated are of the same suit and rank, the two locations need to
be marked so that the isCardMatched(…) function will return true.
bool isCardMatched(int row, int column)
Two integers representing the row and column of the card display.
A boolean indicating if the card at the row and column has been matched with its
bool isGameOver()
A boolean indicating if all the cards on the game board have been matched.
TRUE if all cards are matched and FALSE otherwise.
You will need to submit the source files that you have created along with your
modifications to cs215pgm3.cpp. These files should all be put in a .zip file and upload to
the CS Portal.