You now have a good foundation of C++ programming skills that you can use to develop a larger project. You will implement a program that simulates ESP: Extra Sensory Perception (or, mind-reading)
Here's a program you can show off to your friends! Good luck and have fun!
The rules of ESP are:
There is a deck of 24 cards that looks like this:
Each card has a color and a shape.
There are 4 shapes: CIRCLES, SQUARES, DIAMONDS, and TRIANGLES
There are 6 colors: RED, BLUE, YELLOW, ORANGE, PURPLE, GREEN
For example: one card is BLUE SQUARE
The computer will choose 5 cards from this deck.
The player will try to guess as many of the cards as possible.
The program will display the player’s “ESP Level” based on the number of correct guesses. (see below)
You can represent each of the possible cards with a unique integer.
Create an array for lookup and display purposes, i.e. to map each integer to a shape/color pair.
At the beginning of the program, the computer will choose 5 cards from the deck.
Then, in each round, the player guesses one card by entering a color and a shape.
The program will display whether or not this card matches any of the computer’s 5 cards.
If the player’s card guess matches one of the computer’s cards, the player gets a point.
• make sure there are no duplicate cards generated for the computer
• make sure there are no false positives, i.e.
RED CIRCLE should not be a match if the computer chose RED DIAMOND and GREEN CIRCLE.
• Don’t let the player get duplicate points for guessing the same correct card several times!
• Remember that the cards do not have to be in order to win.
One game continues for 5 rounds, unless the player wants to quit.
The program gives the player the opportunity to quit after each round.
At the end of 5 rounds or whenever the player quits, the program displays:
• the five cards the computer chose (color/shape of each card)
• the cards the player guessed (color/shape of each card)
• the player’s ESP Level (you must have these 4 levels, but you can make up your own messages)
0 points: “Level 1: No ESP at all!”
1-2 points: “Level 2: Some ESP, keep working on it!”
3-4 points: “Level 3: Lots of ESP, try Powerball!”
5 points: “Level 4: ESP expert! Host a TV show!”
The program must match this specification.
Your program must meet the code header and documentation rules, including specifying one full example of input and output for one complete run of the program (0 credit for the project if this is missing)
Please read this specification carefully and thoroughly. Please ask questions if you are not sure what it means.
Pointer Notation required
Use only pointer notation to access array elements throughout your code –
i.e. do not use [ ] brackets anywhere except to declare the arrays.
If this program uses array notation with brackets, there will be a 20 point deduction.
You may use global constants for the size of the arrays.
No global variables! No global arrays!
Declare, implement and call the following functions exactly as specified below.
int main( ) : (25 points)
□ Declare an array to hold the computer’s 5 random card selections
□ Declare another array to hold the player’s 5 card guesses
□ Declare an array to be used to map the card descriptions (shape/color) to unique integer representations
□ Call each of the functions specified below to do the following steps
o Display instructions (call DisplayInstructions() )
o Generate the computer’s selections randomly (call GenerateCards() )
o In a loop:
get a card guess from the player (call GetGuess()), and store it into the player array,
check to see if the guessed card matches one of the computer’s cards (call CheckMatch () )
display a message stating whether or not the guessed card matches
keep score of the player’s matches.
□ Display the two sets of cards side by side. (call DisplayCards () )
□ Display the appropriate ESP Level message (call DisplayESP () )
void DisplayInstructions ( ); (5 points)
DisplayInstructions will display a description of the game, how to play, and how to win.
void GenerateCards (int *); (15 points)
GenerateCards is passed an array, which it fills with integers representing randomly generated cards.
Make sure there are no duplicate cards.
int GetGuess ( ); (15 points)
GetGuess prompts the player to guess a card.
The player enters a shape and a color. This function converts that to an integer that represents that card and returns that integer.
bool CheckMatch (int , int *); (15 points)
CheckMatch is passed an integer representing the player’s guessed card, and the computer’s choice array.
It returns true if it matches, false if it doesn’t.
void DisplayCards (int *, int *); (15 points)
DisplayCards is passed the computer’s and the player’s card arrays.
It displays the two sets of cards side by side, using color/shape.
void DisplayESP (int); (10 points)
DisplayESP is passed the player’s score. It displays the appropriate ESP Level message.