Assignment 10

DUE: Sun June 5, 11 pm
(10% penalty for late submission, up to 1 day late)

Changes, Errata and Helpful Hints

Any changes to this document, typically due to an error on the part of the author, will be logged here.

Collaboration

Collaboration is strongly ENCOURAGED within a programming team, but the program you submit must still represent YOUR OWN original work. Teams should work on the algorithm together, and help debug/test each others code. However, copying code from ANY outside source (any book, current or past students, past solutions, web sites, etc.) is STRICTLY FORBIDDEN. Copy and Paste from another solution, including the solution of a team mate will incur a stiff penalty.

Problem Definition

For the last assignment of this class you will implement one more game. Since you have just finished writing a card and deck class, we will have you implement a card game so that you can use them. The game that you are to implement is called Memory ( a.k.a. Concentration ). The way the game works is that a number of cards are layed face down on the playing surface. Each card on the playing surface has a matching card somewhere else on the playing surface. Players take turns flipping over two of the cards. If the cards match, that player takes the cards and gets another turn. If the cards do not match, they are flipped back over again and the next player takes a turn. Play continues until all of the cards have been removed from the playing surface.

Your game should prompt the players for their names. And then prompt the users when it's their turn. You should also give the players a "New Game" and "Quit" button so that they can start a new game at any time, or quit the game at any time.

The Memory Class

The interface to the Memory class is fairly close to that of the TicTacToe class that you have written in lab. There is a constructor which initiates the game, and then you call a "play" method of the class in order to run the game. Throughout the quarter you have been given the private data members of the class, as well as suggestions for the private methods of the class. For this assignment you will be given the freedom to decide what data you will need to mainatain in you class, as well as what private member functions would be beneficial. As usual, you are only required to keep the public interface of the class the same as it is in the framework. Everything else is up to you.

What to Implement

For this assignment you will implement the Memory class, a main will be provided for you that creates the menu system for the game suite that contains the memory game. To get full credit for the assignment you only need to implement the easy version of the Memory game. ( 12 pairs == 24 cards ) For extra credit you can implement the hard version of the memory game. ( 24 pairs == 48 cards ). Also for extra credit you can implement a single player version of the game. For a single player version of the game, the second players name should be set to "Nobody". You may also display statistics about the number of turns taken and how many matches each player has made. All three of these features are implemented in the sample program.

If you implement any of the extra credit you MUST include a file which MUST be named "README" ( note the capitalization ). In the "README" file you will state which portions of the extra credit that you have implemented. Without the "README" file, your extra credit will not be graded.

To make your life a bit simpler you may want to consider overloading the equality operator for the comparison of two cards. By doing this you can write something like the following :

if ( card1 == card2 )
{
  // do something
}
    

Assignment Framework

For this assignment a framwork will be provided for you which includes all of the files that are necessary for you to complete the assignment. The files included in the framework are the following:

main.cpp
The menu system for the game suite.
Makefile
Your makefile must use the options specified in the class coding standard. The first rule in the makefile shall have a target name of "all" and will compile the program with the default executable name of "a.out". Your makefile must also have a rule with a target name of "clean" which removes the executable and any backup files that were generated by your editor.
memory.h
Declaration of the Memory class. You must stick to the public interface, but the private members are up to you.
memory.cpp
Implementation file for the memory class. You need to complete this file.
global_const.h
Constants describing text in the window. You may not edit this file.
button.h
Declaration of the Button class. You may not edit this file.
button.solution
Object code for the Button class. You may use this if you want, or use your own Button class.
icons.h
Declaration of the icon drawing functions.
icons.solution
Object code for the icon drawing functions.
suits.h
Declaration of the suit drawing functions.
suits.solution
Object code for the suit drawing functions.
clickable.h
Declaration of the Clickable class.
clickable.solution
Object code for the Clickable class. You may use this if you want, or use your own Clickable class.
card.h
Declaration of the Card class.
card.solution
Object code for the Card class. You may use this if you want, or use your own Card class.
deck.h
Declaration of the Deck class.
deck.solution
Object code for the Deck class. You may use this if you want, or use your own Deck class.
randomNumberGenerator.h
A random number generator class that you may use if you are using the random_shuffle algorithm on a vector.
randomNumberGenerator.solution
The object code for the RandomNumberGenerator class.
textviewer.h
Declaration of the TextViewer class.
textviewer.solution
Object code for the TextViewer class. You may use this if you want, or use your own TextViewer class.
tictactoe.h
Declaration of the TicTacToe class.
tictactoe.solution
Object code for the TicTacToe class. You may use this if you want, or use your own TicTacToe class.
tttboard.h
Declaration of the TttBoard class.
tttboard.solution
Object code for the TttBoard class. You may use this if you want, or use your own TttBoard class.
tttcell.h
Declaration of the TttCell class.
tttcell.solution
Object code for the TttCell class. You may use this if you want, or use your own TttCell class.
instructions/
A folder containing instructions for the games.

You may download the framework right-clicking and save-as here. To uncompress the framework archive you should type:

tar -xzvf <framework_file>

where <framework_file> is the name of the file that you downloaded.

What To Turn In

Submit your work electronically to the correct folder on the cs secure server. Don't forget to include the header template at the top of each file that you submit.

For this assignment you will turn in the following files:

Example

You can download a sample program right-clicking and save-as here. You will probably need to change the permissions on assn10_sample so that it is user executable. You can do this with the command:

chmod u+x assn10_sample

Grading Rubric (10 pts total)

Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.

The points for this assignment will be distributed as follows:

Points Feature Description
2 pts Program compiles( And files represent an attempt at completing the assignment )
3 pts Adherence to the class coding standard
-- ( .5 pts ) Program does not use global variables or objects
-- ( .5 pts ) Good variable and function names
-- ( .5 pts ) Proper indentation and spacing
-- ( .5 pts ) Good comments ( including header and function comments )
-- ( .5 pts ) No line wraps
-- ( .5 pts ) Other miscellaneous parts of the standard.
.5 pts Prompt for players names.
.5 pts Prompt players when it is their turn.
.5 pts Cards are layed out in a reasonable mannor. ( ie. 24 cards are present )
.5 pts Players are able to pick ( turn over ) two cards.
.5 pts Non-matches are flipped back over.
1 pts Matches are removed from the board.
1.5 pts Game is playable to the end.
1 pts ( Extra Credit ) Statistics on number of turns and number of matches are displayed.
1 pts ( Extra Credit ) Hard Game is implemented.
1 pts ( Extra Credit ) Single player game is implemented.