QUESTION

Text
Image


Fill in all the missing portions of the starter code below to make a program that checks whether the user was able to correctly guess a secret card.

//@todo introductory comment
#include <iostream>
#include <ctime>

using namespace std;

enum card_suit{CLUB,DIAMOND,HEART,SPADE};

//@todo choose secret suit and value, the code should run as normal is these values are changed
const card_suit SECRET_SUIT = ;
const int SECRET_VALUE = ;

//Function to read in card suit from user input
//Precondition:
//Postcondition: Returns the card_suit value of the user's choice

card_suit read_suit();

//@todo function comment
void print_suit(card_suit guessed);

int main() {
cout << "I have selected a secret card. Which card is it?" << endl;

//Read in user guess for suit
card_suit guessed_suit = read_suit();

//Read in user guess for value
int guessed_value;
cout << "Guess a value (1-13): ";
cin >> guessed_value;

//Decision of whether they are correct and print the result
//@
todo determine a suitable condition for the if statement
if(){
cout << "Your guess of " << guessed_value << " of ";
print_suit(guessed_suit);
cout << " is correct!";
}else{
cout << "Your guess of " << guessed_value << " of ";
print_suit(guessed_suit);
cout << " is incorrect!" << endl;
}

return 0;
}

card_suit read_suit(){
card_suit guessed;
string user_guess;

cout << "Guess a suit (club,diamond,heart,spade): ";
cin >> user_guess;

//@todo use a switch to initialize the card_suit guessed based on the string user_guess

return guessed;
}

void print_suit(card_suit guessed){
switch(guessed){
case CLUB:
cout << "club";
break;
case DIAMOND:
cout << "diamond";
break;
case HEART:
cout << "heart";
break;
case SPADE:
cout << "spade";
break;
default:
cout << "unknown suit";
}
}

Public Answer

VFDEFY The First Answerer